Table of Contents

Class SpanEventSerializer

Namespace
Excalibur.Dispatch.Serialization
Assembly
Excalibur.Dispatch.dll

Event serializer implementation using the pluggable serialization infrastructure.

public sealed class SpanEventSerializer : IEventSerializer
Inheritance
SpanEventSerializer
Implements
Inherited Members
Extension Methods

Remarks

This serializer implements IEventSerializer by delegating to the configured ISerializer (the current/default serializer, typically JSON).

Constructors

SpanEventSerializer(ISerializer)

Initializes a new instance of SpanEventSerializer using the specified pluggable serializer.

public SpanEventSerializer(ISerializer pluggable)

Parameters

pluggable ISerializer

The underlying pluggable serializer (typically MemoryPack).

Exceptions

ArgumentNullException

Thrown when pluggable is null.

SpanEventSerializer(ISerializerRegistry)

Initializes a new instance of SpanEventSerializer using the registry to obtain the MemoryPack serializer.

public SpanEventSerializer(ISerializerRegistry registry)

Parameters

registry ISerializerRegistry

The serializer registry.

Exceptions

ArgumentNullException

Thrown when registry is null.

InvalidOperationException

Thrown when no serializer is available.

Methods

DeserializeEvent(byte[], Type)

Deserializes an event from bytes.

public IDomainEvent DeserializeEvent(byte[] data, Type eventType)

Parameters

data byte[]

The serialized event data.

eventType Type

The type of event to deserialize.

Returns

IDomainEvent

The deserialized event.

DeserializeEvent(ReadOnlySpan<byte>, Type)

Deserializes an event from a read-only span (zero-copy).

[RequiresDynamicCode("Deserialization of events requires dynamic code generation for type inspection")]
[RequiresUnreferencedCode("Deserialization may reference types not preserved during trimming")]
public IDomainEvent DeserializeEvent(ReadOnlySpan<byte> data, Type eventType)

Parameters

data ReadOnlySpan<byte>
eventType Type

Returns

IDomainEvent

DeserializeSnapshot(ReadOnlySpan<byte>, Type)

Deserializes a snapshot from a read-only span (zero-copy).

[RequiresDynamicCode("Deserialization of snapshots requires dynamic code generation for type inspection")]
[RequiresUnreferencedCode("Deserialization may reference types not preserved during trimming")]
public object DeserializeSnapshot(ReadOnlySpan<byte> data, Type snapshotType)

Parameters

data ReadOnlySpan<byte>
snapshotType Type

Returns

object

GetSnapshotSize(object)

Gets the required buffer size for serializing a snapshot.

[RequiresDynamicCode("Size calculation may require dynamic code generation")]
[RequiresUnreferencedCode("Size calculation may reference types not preserved during trimming")]
public int GetSnapshotSize(object snapshot)

Parameters

snapshot object

Returns

int

GetTypeName(Type)

Gets the type name for serialization.

public string GetTypeName(Type type)

Parameters

type Type

The type to get the name for.

Returns

string

Type name for storage.

ResolveType(string)

Resolves a type from its stored name.

public Type ResolveType(string typeName)

Parameters

typeName string

The stored type name.

Returns

Type

The resolved type.

SerializeEvent(IDomainEvent)

Serializes an event to bytes.

public byte[] SerializeEvent(IDomainEvent domainEvent)

Parameters

domainEvent IDomainEvent

The event to serialize.

Returns

byte[]

Serialized event data.

SerializeSnapshot(object, Span<byte>)

Serializes a snapshot to a caller-provided span buffer.

[RequiresDynamicCode("Serialization of snapshots requires dynamic code generation for type inspection")]
[RequiresUnreferencedCode("Serialization may reference types not preserved during trimming")]
public int SerializeSnapshot(object snapshot, Span<byte> buffer)

Parameters

snapshot object
buffer Span<byte>

Returns

int