Table of Contents

Interface ISerializerRegistry

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

Registry for managing available pluggable serializers and the currently configured serializer.

public interface ISerializerRegistry
Extension Methods

Remarks

This interface defines 5 core methods for serializer lifecycle and lookup. Convenience query methods (GetByName, IsRegistered) are available as extension methods in SerializerRegistryExtensions.

The serializer registry manages the set of available serializers for internal persistence (Outbox, Inbox, Event Store). It maintains:

  • A mapping of serializer IDs to ISerializer implementations
  • A mapping of serializer names to IDs for lookup by name
  • The currently active serializer for new message serialization

Thread Safety: Implementations must be thread-safe. The registry may be read concurrently during serialization/deserialization while occasionally being written to during configuration or migration.

Methods

GetAll()

Gets all registered serializers.

IReadOnlyCollection<(byte Id, string Name, ISerializer Serializer)> GetAll()

Returns

IReadOnlyCollection<(byte Id, string Name, ISerializer Serializer)>

A read-only collection of tuples containing (ID, Name, Serializer) for each registered serializer.

Remarks

This method is useful for diagnostics, migration tools, and error messages that need to list available serializers.

GetById(byte)

Gets a serializer by its ID.

ISerializer? GetById(byte id)

Parameters

id byte

The serializer ID (from payload magic byte).

Returns

ISerializer

The serializer, or null if not registered.

GetCurrent()

Gets the currently configured serializer.

(byte Id, ISerializer Serializer) GetCurrent()

Returns

(byte Id, ISerializer Serializer)

A tuple containing the current serializer's ID and implementation.

Exceptions

InvalidOperationException

Thrown when no current serializer is configured. Call SetCurrent(string) first.

Register(byte, ISerializer)

Registers a serializer with a unique ID.

void Register(byte id, ISerializer serializer)

Parameters

id byte

The serializer ID (must be 1-254). Use SerializerIds constants for framework serializers or values in the custom range (200-254) for custom serializers.

serializer ISerializer

The serializer implementation.

Exceptions

ArgumentNullException

Thrown when serializer is null.

ArgumentException

Thrown when:

  • ID is 0 or 255 (reserved values)
  • ID is already registered
  • Serializer name is already registered

SetCurrent(string)

Sets the current serializer to use for new messages.

void SetCurrent(string serializerName)

Parameters

serializerName string

The name of the serializer (must be registered).

Exceptions

ArgumentException

Thrown when the serializer name is not registered.

ArgumentNullException

Thrown when serializerName is null or whitespace.