Shuttle.Core.Serialization
10.0.7
dotnet add package Shuttle.Core.Serialization --version 10.0.7
NuGet\Install-Package Shuttle.Core.Serialization -Version 10.0.7
<PackageReference Include="Shuttle.Core.Serialization" Version="10.0.7" />
paket add Shuttle.Core.Serialization --version 10.0.7
#r "nuget: Shuttle.Core.Serialization, 10.0.7"
// Install Shuttle.Core.Serialization as a Cake Addin
#addin nuget:?package=Shuttle.Core.Serialization&version=10.0.7
// Install Shuttle.Core.Serialization as a Cake Tool
#tool nuget:?package=Shuttle.Core.Serialization&version=10.0.7
Shuttle.Core.Serialization
PM> Install-Package Shuttle.Core.Serialization
An implementation of the ISerializer
interface is used to serialize objects into a Stream
.
The DefaultSerializer
makes use of the standard .NET xml serialization functionality.
Methods
Serialize
Stream Serialize(object message);
Returns the message object
as a Stream
.
Deserialize
object Deserialize(Type type, Stream stream);
Deserializes the Stream
into an obejct
of the given type.
ISerializerRootType
The ISerializerRootType
interface is an optional interface that serializer implementations can use that allows the developer to specify explicit object types contained within a root type.
The DefaultSerializer
implements this interface and it is recommended that you explicitly register types with the same name, but in different namespaes, that will be serialized within the same root type to avoid any conflicts later down the line.
For instance, the following two types will cause issues when used in the root Complex
type as they both serialize to the same name and the .Net serializer cannot seem to distinguish the difference:
namespace Serializer.v1
{
public class MovedEvent
{
public string Where { get; set; }
}
}
namespace Serializer.v2
{
public class MovedEvent
{
public string Where { get; set; }
}
}
namespace Serializer
{
public class Complex
{
public v1.MovedEvent { get; set; }
public v2.MovedEvent { get; set; }
}
}
By explicitly specifying the types the DefaultSerializer
will add a namespace that will cause the types to be correctly identified.
AddSerializerType
void AddSerializerType(Type root, Type contained);
Specify the contained
tpe that is used within te root
type somewhere.
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net461 net462 net463 net47 net471 net472 net48 net481 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
- Shuttle.Core.Contract (>= 11.0.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Shuttle.Core.Serialization:
Package | Downloads |
---|---|
Shuttle.Esb
Contains the core Shuttle.Esb assembly that should always be referenced when building Shuttle.Esb solutions. |
|
Shuttle.Recall
Event sourcing mechanism. |
|
Shuttle.Core.Json
Json.Net implementation of the `ISerializer` interface. |
|
Shuttle.Core.Mediator.OpenTelemetry
OpenTelemetry instrumentation for Shuttle.Core.Mediator implementations. |
GitHub repositories
This package is not used by any popular GitHub repositories.