Struct SerializationContext
- Namespace
- Nerdbank.MessagePack
- Assembly
- Nerdbank.MessagePack.dll
Context that flows through the serialization process.
public record struct SerializationContext : IEquatable<SerializationContext>
- Implements
- Inherited Members
Constructors
SerializationContext()
Initializes a new instance of the SerializationContext struct.
public SerializationContext()
Properties
MaxDepth
Gets or sets the remaining depth of the object graph to serialize or deserialize.
public int MaxDepth { readonly get; set; }
Property Value
- int
The default value is 64.
Remarks
Exceeding this depth will result in a MessagePackSerializationException being thrown from DepthStep().
UnflushedBytesThreshold
Gets a hint as to the number of bytes to write into the buffer before serialization will flush the output.
public int UnflushedBytesThreshold { readonly get; init; }
Property Value
- int
The default value is 64KB.
Methods
DepthStep()
Decrements the depth remaining.
public void DepthStep()
Remarks
Converters that (de)serialize nested objects should invoke this once before passing the context to nested (de)serializers.
Exceptions
- MessagePackSerializationException
Thrown if the depth limit has been exceeded.
GetConverter<T>()
Gets a converter for a specific type.
public MessagePackConverter<T> GetConverter<T>() where T : IShapeable<T>
Returns
- MessagePackConverter<T>
The converter.
Type Parameters
T
The type to be converted.
Remarks
This method is intended only for use by custom converters in order to delegate conversion of sub-values.
Exceptions
- InvalidOperationException
Thrown if no serialization operation is in progress.
GetConverter<T, TProvider>()
Gets a converter for a specific type.
public MessagePackConverter<T> GetConverter<T, TProvider>() where TProvider : IShapeable<T>
Returns
- MessagePackConverter<T>
The converter.
Type Parameters
T
The type to be converted.
TProvider
The type that provides the shape of the type to be converted.
Remarks
This method is intended only for use by custom converters in order to delegate conversion of sub-values.
Exceptions
- InvalidOperationException
Thrown if no serialization operation is in progress.