assistant.net.serialization 0.5.182

dotnet add package assistant.net.serialization --version 0.5.182                
NuGet\Install-Package assistant.net.serialization -Version 0.5.182                
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="assistant.net.serialization" Version="0.5.182" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add assistant.net.serialization --version 0.5.182                
#r "nuget: assistant.net.serialization, 0.5.182"                
#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 assistant.net.serialization as a Cake Addin
#addin nuget:?package=assistant.net.serialization&version=0.5.182

// Install assistant.net.serialization as a Cake Tool
#tool nuget:?package=assistant.net.serialization&version=0.5.182                

assistant.net.serialization

Common serializer implementation extensible for using different type/format that can be easily extended for new formats including theirs own specific tuning extensions. It gives an opportunuty to isolate an application from specific serialization format and manage it centralizely.

Default configuration

To add serialization one of methods should be called:

var services = new ServiceCollection()
    .AddSerializer(b => ...) // adds dependencies and initial configuration
    .ConfigureSerializer(b => ...); // appends existing configuration (no dependencies are added)

where a specific format should be selected for serialization

services.ConfigureSerializer(b => b.UseFormat()); // e.g. JSON or others

and types allowed for serialization


services.ConfigureSerializer(b => b
    .AddType<SomeModel>() // by registering specific types
    .AllowAnyType()); // or allowing any type

Named configuration

Serializer implementation is based on named options so you can have multiple named serializers with different configurations.

var provider = new ServiceCollection()
    .AddSerializer()
    .ConfigureSerializer("name-1", o => o.UseJson().AddType<DateTime>())
    .ConfigureSerializer("name-2", o => o.UseProto().AddType<TimeSpan>())
    .BuildServiceProvider();

using var scope1 = provider.CreateScopeWithNamedOptionContext("name-1");
using var scope2 = provider.CreateScopeWithNamedOptionContext("name-2");

var serializer1 = scope1.ServiceProvider.GetRequiredService<ISerializer<DateTime>>();
var serializer2 = scope2.ServiceProvider.GetRequiredService<ISerializer<TimeSpan>>();

Serializer resolving

Once seralization was properly configured a specific serializer can be resolved directly

var serializer1 = provider.GetRequiredService<ISerializer<SomeModel>>();
var serializer2 = provider.GetRequiredService<ISerializer<AnotherModel>>();

or via serialization factory

var factory = provider.GetRequiredService<ISerializerFactory>();
var serializer1 = factory.Create(typeof(SomeModel));
var serializer2 = factory.Create<AnotherModel>();

Pay attention, if serialization isn't properly configured, resolving a serializer will throw an exception.

Available formats

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on assistant.net.serialization:

Package Downloads
assistant.net.serialization.json

JSON serializer implementation.

assistant.net.serialization.proto

Protocol Buffer serializer implementation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.182 796 5/8/2023