Class JsonCompressedStreamSerializationBase
- Namespace
- Arc4u.Serializer
- Assembly
- Arc4u.Serializer.JSon.dll
Base class of Json serialization based on compressed streams.
public abstract class JsonCompressedStreamSerializationBase
- Inheritance
-
JsonCompressedStreamSerializationBase
- Derived
- Inherited Members
Constructors
JsonCompressedStreamSerializationBase()
Construct an instance with default options
[RequiresUnreferencedCode("This constructor is not suitable for AOT. Use the constructor with JsonSerializerContext for AOT compatibility.")]
protected JsonCompressedStreamSerializationBase()
JsonCompressedStreamSerializationBase(JsonSerializerOptions)
Construct an instance, optionally specifying compression and other Json serializer options
[RequiresUnreferencedCode("This constructor is not suitable for AOT. Use the constructor with JsonSerializerContext for AOT compatibility.")]
protected JsonCompressedStreamSerializationBase(JsonSerializerOptions options)
Parameters
optionsJsonSerializerOptionsJson serializer options
JsonCompressedStreamSerializationBase(JsonSerializerContext)
Construct an instance, optionally specifying compression and a serialization context. This is used for source generation, implemented in .NET 6 or later (https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation?pivots=dotnet-6-0)
protected JsonCompressedStreamSerializationBase(JsonSerializerContext context)
Parameters
contextJsonSerializerContextJson context for source generation
Properties
RecyclableMemoryStreamManager
Gets the pool of recyclable memory streams used to avoid large allocations.
protected virtual RecyclableMemoryStreamManager RecyclableMemoryStreamManager { get; }
Property Value
- RecyclableMemoryStreamManager
SerializerType
Gets the value written in the SerializerType tag of the current Activity.
protected abstract string SerializerType { get; }
Property Value
Methods
InternalDeserialize(Stream, Type)
Reads a value of the given type from a UTF-8 JSON stream, using the source generation context if one was given, otherwise the serializer options.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The constructor is marked with RequiresUnreferencedCode.")]
[UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "The constructor is marked with RequiresUnreferencedCode.")]
protected object? InternalDeserialize(Stream utf8json, Type returnType)
Parameters
utf8jsonStreamThe stream that contains the JSON.
returnTypeTypeThe type of the object to create.
Returns
- object
The deserialized object.
InternalDeserialize<T>(Stream)
Reads a value from a UTF-8 JSON stream, using the source generation context if one was given, otherwise the serializer options.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The constructor is marked with RequiresUnreferencedCode.")]
[UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "The constructor is marked with RequiresUnreferencedCode.")]
protected T? InternalDeserialize<T>(Stream utf8json)
Parameters
utf8jsonStreamThe stream that contains the JSON.
Returns
- T
The deserialized value.
Type Parameters
TThe expected type of the value.
InternalSerialize<T>(Stream, T)
Writes the value as UTF-8 JSON to the stream, using the source generation context if one was given, otherwise the serializer options.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The constructor is marked with RequiresUnreferencedCode.")]
[UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "The constructor is marked with RequiresUnreferencedCode.")]
protected void InternalSerialize<T>(Stream utf8json, T value)
Parameters
utf8jsonStreamThe stream that receives the JSON.
valueTThe value to serialize.
Type Parameters
TThe type of the value.