An implementation of ICachingSerializer based on JsonSerializer.
Implements
Namespace: Metalama.Patterns.Caching.Serializers
Assembly: Metalama.Patterns.Caching.Backend.dll
Syntax
public class JsonCachingSerializer : ICachingSerializerRemarks
This serializer stores the assembly-qualified type name along with the JSON payload, allowing for polymorphic deserialization of cached values.
To customize type name resolution (for example, for type forwarding scenarios), override the GetTypeName(Type) and ResolveTypeName(string) methods.
A union of C# 15 is serialized by a converter of this class rather than by the default object
conversion of JsonSerializer. The Value property of a union has no setter, so the default
conversion writes the value of the current case and deserializes the default value of the union.
Constructors
| Name | Description |
|---|---|
| JsonCachingSerializer(JsonSerializerOptions?) | Initializes a new instance of the JsonCachingSerializer class. |
Methods
| Name | Description |
|---|---|
| Deserialize(BinaryReader) | Deserializes a byte array into an object. |
| GetTypeName(Type) | Gets the type name to store in the serialized data. Override to customize type name mapping. |
| ResolveTypeName(string) | Resolves a type name from the serialized data back to a Type. Override to customize type resolution. |
| Serialize(object?, BinaryWriter) | Serializes an object into a byte array. |