Skip to content

Commit 28bcfdf

Browse files
committed
21.0.1-beta / docs.
1 parent 090f9cf commit 28bcfdf

File tree

2 files changed

+12
-71
lines changed

2 files changed

+12
-71
lines changed

README.md

Lines changed: 10 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,17 @@
11
# Shuttle.Core.Serialization
22

3-
```
4-
PM> Install-Package Shuttle.Core.Serialization
3+
## Installation
4+
5+
```bash
6+
dotnet add package Shuttle.Core.Serialization
57
```
68

7-
The following implementations of the `ISerializer` interface is used to serialize objects into a `Stream`:
9+
The following implementation of the `ISerializer` interface is used to serialize objects into a `Stream`:
810

9-
- `XmlSerializer` makes use of the standard .NET XML serialization functionality.
10-
- `JsonSerializer` makes use of the `System.Test.Json` serialization functionality.
11+
- `JsonSerializer` makes use of the `System.Text.Json` serialization functionality.
1112

1213
## Usage
1314

14-
### XmlSerializer
15-
16-
``` c#
17-
services.AddXmlSerializer(builder => {
18-
builder.Options = new XmlSerializerOptions
19-
{
20-
};
21-
22-
// or
23-
24-
buidler.Options.option = value;
25-
});
26-
```
27-
28-
The `builder.Options` contains properties that map to [XmlWriterSettings](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlwritersettings?view=net-8.0) as well as [XmlDictionaryReaderQuotas](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmldictionaryreaderquotas?view=net-8.0).
29-
3015
### JsonSerializer
3116

3217
``` c#
@@ -37,7 +22,7 @@ services.AddJsonSerializer(builder => {
3722

3823
// or
3924
40-
buidler.Options.option = value;
25+
builder.Options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
4126
});
4227
```
4328

@@ -48,60 +33,16 @@ The `builder.Options` is of type [JsonSerializerOptions](https://docs.microsoft.
4833
### Serialize
4934

5035
``` c#
51-
Task<Stream> SerializeAsync(object message);
36+
Task<Stream> SerializeAsync(object instance, CancellationToken cancellationToken = default);
5237
```
5338

54-
Returns the message `object` as a `Stream`.
39+
Returns the `object` as a `Stream`.
5540

5641
### Deserialize
5742

5843
``` c#
59-
Task<object> DeserializeAsync(Type type, Stream stream);
44+
Task<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default);
6045
```
6146

6247
Deserializes the `Stream` into an `object` of the given type.
6348

64-
## ISerializerRootType
65-
66-
The `XmlSerializer` implements the `ISerializerRootType` interface which is an optional interface that serializer implementations can use that allows the developer to specify explicit object types contained within a root type.
67-
68-
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.
69-
70-
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:
71-
72-
``` c#
73-
namespace Serializer.v1
74-
{
75-
public class MovedEvent
76-
{
77-
public string Where { get; set; }
78-
}
79-
}
80-
81-
namespace Serializer.v2
82-
{
83-
public class MovedEvent
84-
{
85-
public string Where { get; set; }
86-
}
87-
}
88-
89-
namespace Serializer
90-
{
91-
public class Complex
92-
{
93-
public v1.MovedEvent { get; set; }
94-
public v2.MovedEvent { get; set; }
95-
}
96-
}
97-
```
98-
99-
By explicitly specifying the types the `XmlSerializer` will add a namespace that will cause the types to be correctly identified.
100-
101-
### AddSerializerType
102-
103-
``` c#
104-
void AddSerializerType(Type root, Type contained);
105-
```
106-
107-
Specify the `contained` type that is used within the `root` type.

Shuttle.Core.Serialization/Shuttle.Core.Serialization.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Shuttle.Core.Contract" Version="21.0.0-alpha" />
16+
<PackageReference Include="Shuttle.Core.Contract" Version="21.0.1-beta" />
1717
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
1818
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.1" />
1919
</ItemGroup>
@@ -35,7 +35,7 @@
3535

3636
<PropertyGroup>
3737
<Description>Serialization adapter.</Description>
38-
<Version>21.0.0-alpha</Version>
38+
<Version>21.0.1-beta</Version>
3939
<PackageProjectUrl>https://github.com/shuttle/Shuttle.Core.Serialization</PackageProjectUrl>
4040
<RepositoryUrl>https://github.com/shuttle/Shuttle.Core.Serialization.git</RepositoryUrl>
4141
<PackageTags>shuttle serialization</PackageTags>

0 commit comments

Comments
 (0)