Class JsonCompressedStreamSerialization
- Namespace
- Arc4u.Serializer
- Assembly
- Arc4u.Serializer.JSon.dll
Base class of Json serialization based on compressed streams.
public abstract class JsonCompressedStreamSerialization : JsonCompressedStreamSerializationBase, IObjectSerialization
- Inheritance
-
JsonCompressedStreamSerialization
- Implements
- Derived
- Inherited Members
Constructors
JsonCompressedStreamSerialization()
Construct with default options
[RequiresUnreferencedCode("This constructor is not suitable for AOT. Use the constructor with JsonSerializerContext for AOT compatibility.")]
protected JsonCompressedStreamSerialization()
JsonCompressedStreamSerialization(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 JsonCompressedStreamSerialization(JsonSerializerOptions options)
Parameters
optionsJsonSerializerOptionsJson serializer options
JsonCompressedStreamSerialization(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 JsonCompressedStreamSerialization(JsonSerializerContext context)
Parameters
contextJsonSerializerContextJson context for source generation
Methods
CreateForCompression(Stream)
Wraps the stream in a compression stream. The underlying stream must be left open.
protected abstract Stream CreateForCompression(Stream stream)
Parameters
streamStreamThe stream that receives the compressed data.
Returns
- Stream
The compression stream.
CreateForDecompression(Stream)
Wraps the stream in a decompression stream.
protected abstract Stream CreateForDecompression(Stream stream)
Parameters
streamStreamThe stream that contains the compressed data.
Returns
- Stream
The decompression stream.
Deserialize(byte[], Type)
Deserializes bytes to an object of a type known only at runtime.
public object? Deserialize(byte[] data, Type objectType)
Parameters
Returns
- object
The deserialized object.
Deserialize<T>(byte[])
Deserializes bytes produced by Serialize<T>(T).
public T? Deserialize<T>(byte[] data)
Parameters
databyte[]The serialized bytes.
Returns
- T
The deserialized value.
Type Parameters
TThe expected type of the value.
Serialize<T>(T)
Serializes a value to bytes.
public byte[] Serialize<T>(T value)
Parameters
valueTThe value to serialize.
Returns
- byte[]
The serialized bytes.
Type Parameters
TThe type of the value.