webBeta.NSerializer
1.0.1
dotnet add package webBeta.NSerializer --version 1.0.1
NuGet\Install-Package webBeta.NSerializer -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="webBeta.NSerializer" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add webBeta.NSerializer --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: webBeta.NSerializer, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install webBeta.NSerializer as a Cake Addin
#addin nuget:?package=webBeta.NSerializer&version=1.0.1
// Install webBeta.NSerializer as a Cake Tool
#tool nuget:?package=webBeta.NSerializer&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
webBeta NSerializer
What is webBeta NSerializer?
YML based serializer for .Net Core. Based on JMS serializer https://jmsyst.com/libs/serializer/master/reference/yml_reference
It is a fork of our YML based serializer for Java.
Steps to create a NSerializer instance.
- Create a cache provider.
public class MyCache : ICache
{
public string Get(string key)
{
return null;
}
public void Set(string key, string content)
{
}
public void Remove(string key)
{
}
}
- Create a configuration provider.
public class MyConfigurationProvider : IConfigurationProvider
{
private readonly Dictionary<string, object> _conf;
public MyConfigurationProvider(Dictionary<string, object> conf)
{
_conf = conf;
}
public bool GetBoolean(string key, bool defaultValue)
{
return !_conf.ContainsKey(key) ? defaultValue : bool.Parse(_conf[key].ToString());
}
public string GetString(string key, string defaultValue)
{
return !_conf.ContainsKey(key) ? defaultValue : _conf[key].ToString();
}
}
- Create an environment provider.
public class MyEnvironment : IEnvironment
{
public bool IsProd()
{
return true;
}
}
- Then build the NSerializer.
NSerializer serializer = NSerializerBuilder.Build()
.WithCache(cache)
.WithConfigurationProvider(configurationProvider)
.WithEnvironment(environment)
.Get();
- Optionally, add a logger instance:
public class MyLogger : ILogger
{
public Level GetLevel()
{
return Level.ERROR;
}
public void SetLevel(Level level)
{
}
public void Error(string message)
{
}
}
serializer.SetLogger(logger);
Quick examples
Class Foo:
namespace Foo.Bar
{
public class Foo {
private string bar = "foobar";
public string AutoPropertyString { get; set; } = "Foo Autoproperty!";
public string GetBar() {
return bar;
}
public long GetCalc() {
return 2 + 2;
}
}
}
Yml file (named Foo.Bar.Foo.yml
):
Foo.Bar.Foo:
virtual_properties:
GetCalc:
serialized_name: calc
groups: [barGroup]
properties:
bar:
groups: [fooGroup]
AutoPropertyString:
groups: [autoGroup]
Usage:
serializer.Serialize(fooInstance, "fooGroup", "barGroup", "autoGroup");
// it will return
// {"bar": "foobar", "calc": 4, "autoPropertyString": "Foo Autoproperty!"}
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Newtonsoft.Json (>= 12.0.3)
- YamlDotNet.NetCore (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on webBeta.NSerializer:
Package | Downloads |
---|---|
webBeta.NSerializer.AspNetCore
ASP.NET Core plugin for NSerializer |
GitHub repositories
This package is not used by any popular GitHub repositories.
Implements cache metadata provider