Interface ISerializationContext
Provides stateful context information threaded through a single serialization or deserialization operation. Each top-level call to ScyllaSerialization creates a fresh context that is passed down to every ITypeSerializer and ITypeSerializer<T> involved in the operation.
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public interface ISerializationContext
Remarks
The context serves three distinct purposes during an operation:
- Depth tracking - PushDepth() and PopDepth() bracket each nested object or collection so that the engine can detect and abort pathologically deep or infinite object graphs before a stack overflow occurs.
- Reference tracking - the shared ReferenceTracker detects cyclic references and, depending on the active ReferenceHandling policy, either preserves them, ignores them, or raises an error.
- Serializer resolution - GetSerializer(Type) and GetSerializer<T>() locate the most specific ITypeSerializer for a given type, first consulting the per-settings custom serializer registry before falling back to the global engine registry.
Context instances are not reused across operations. The concrete implementation SerializationContext is constructed internally by ScyllaSerialization and should not need to be instantiated directly by application code.
Properties
CurrentDepth
Gets the zero-based nesting depth at which the engine is currently operating.
The depth starts at 0 for the root object and increments by one for each
nested object or collection encountered.
Declaration
int CurrentDepth { get; }
Property Value
| Type | Description |
|---|---|
| int | An integer in the range |
See Also
IsMaxDepthReached
Gets a value indicating whether the operation has reached the maximum allowed
nesting depth as defined by MaxDepth.
When true, the next call to PushDepth() will throw a
SerializationException.
Declaration
bool IsMaxDepthReached { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
ReferenceTracker
Gets the reference tracker that monitors object identity across the entire operation, enabling cycle detection and, when Preserve is active, reference ID assignment and resolution.
Declaration
ReferenceTracker ReferenceTracker { get; }
Property Value
| Type | Description |
|---|---|
| ReferenceTracker | The ReferenceTracker instance shared for the duration of this
operation. Never |
See Also
Settings
Gets the settings that govern the current serialization or deserialization operation, including the chosen output format, null/default-value handling policies, maximum recursion depth, and any per-operation custom type serializers.
Declaration
SerializationSettings Settings { get; }
Property Value
| Type | Description |
|---|---|
| SerializationSettings | The SerializationSettings instance provided when the operation started.
Never |
Methods
GetSerializer(Type)
Returns the most specific ITypeSerializer registered for the
specified runtime type, or null if no serializer
is registered for that type.
Declaration
ITypeSerializer GetSerializer(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The exact Type for which a serializer is required. Must not be
|
Returns
| Type | Description |
|---|---|
| ITypeSerializer | An ITypeSerializer capable of handling |
See Also
GetSerializer<T>()
Returns a strongly-typed ITypeSerializer<T> for the type
parameter T, or null if no typed serializer
has been registered for that type.
Declaration
ITypeSerializer<T> GetSerializer<T>()
Returns
| Type | Description |
|---|---|
| ITypeSerializer<T> | An ITypeSerializer<T> for |
Type Parameters
| Name | Description |
|---|---|
| T | The compile-time type for which a serializer is required. |
See Also
PopDepth()
Decrements the current nesting depth by one level to signal that the engine
has finished serializing or deserializing a nested object or collection.
Safe to call when depth is already 0 - it is a no-op in that case.
Declaration
void PopDepth()
See Also
PushDepth()
Increments the current nesting depth by one level to signal that the engine is entering a nested object or collection. Must be paired with a subsequent call to PopDepth().
Declaration
void PushDepth()
Exceptions
| Type | Condition |
|---|---|
| SerializationException | Thrown when the incremented depth would exceed MaxDepth, which typically indicates either a circular reference that bypassed ReferenceTracker or a legitimate but unusually deep object graph. |