Class TypeSerializerAdapter<T>
Adapter that wraps a strongly-typed ITypeSerializer<T> as the non-generic ITypeSerializer interface, enabling it to be stored and invoked through the engine's runtime type-keyed registry without requiring generic type arguments at the call site.
Implements
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public sealed class TypeSerializerAdapter<T> : ITypeSerializer
Type Parameters
| Name | Description |
|---|---|
| T | The type that the wrapped ITypeSerializer<T> handles. Used to
implement TargetType as |
Remarks
TypeSerializerAdapter<T> instances are created automatically by RegisterSerializer<T>(ITypeSerializer<T>) and RegisterSerializer<T>(ITypeSerializer<T>). Application code does not need to instantiate this class directly.
The adapter simply forwards WriteObject(object, IScyllaWriter, ISerializationContext) and
ReadObject(IScyllaReader, ISerializationContext) calls to Write(T, IScyllaWriter, ISerializationContext) and
Read(IScyllaReader, ISerializationContext) respectively, performing the necessary
cast between object and T.
Constructors
TypeSerializerAdapter(ITypeSerializer<T>)
Initializes a new TypeSerializerAdapter<T> that delegates all serialization and deserialization calls to the supplied typed serializer.
Declaration
public TypeSerializerAdapter(ITypeSerializer<T> innerSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| ITypeSerializer<T> | innerSerializer | The strongly-typed ITypeSerializer<T> to wrap. Must not be
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Properties
TargetType
Gets the Type that this serializer is responsible for handling. The engine uses this value as the dictionary key when storing and retrieving serializers from its registry.
Declaration
public Type TargetType { get; }
Property Value
| Type | Description |
|---|---|
| Type | The exact Type this serializer handles. For
TypeSerializerAdapter<T>, this is always |
Methods
ReadObject(IScyllaReader, ISerializationContext)
Reads and reconstructs a value from reader using this
serializer's format-specific decoding. This is the non-generic counterpart of
Read(IScyllaReader, ISerializationContext).
Declaration
public object ReadObject(IScyllaReader reader, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| IScyllaReader | reader | The format-specific reader positioned at the beginning of the serialized value.
Must not be |
| ISerializationContext | context | The active serialization context providing settings, depth tracking, and reference
tracking. Must not be |
Returns
| Type | Description |
|---|---|
| object | The deserialized value as a boxed object. May return |
See Also
WriteObject(object, IScyllaWriter, ISerializationContext)
Writes the supplied value to writer using this serializer's
format-specific encoding. This is the non-generic counterpart of
Write(T, IScyllaWriter, ISerializationContext).
Declaration
public void WriteObject(object value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The object to serialize. May be |
| IScyllaWriter | writer | The format-specific writer that receives the serialized output (e.g., a JSON
or binary stream). Must not be |
| ISerializationContext | context | The active serialization context, providing access to settings, depth tracking,
and reference tracking for the ongoing operation. Must not be |