Table of Contents

Class PluggableSerializationServiceCollectionExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
Excalibur.Dispatch.dll

Extension methods for configuring pluggable serialization services.

public static class PluggableSerializationServiceCollectionExtensions
Inheritance
PluggableSerializationServiceCollectionExtensions
Inherited Members

Methods

AddEventSerializer(IServiceCollection)

Adds the event serializer to the service collection.

[RequiresUnreferencedCode("Registers the reflection-based JsonEventSerializer. Use an AOT-safe serializer (e.g. AotJsonEventSerializer) for trimmed/AOT apps.")]
[RequiresDynamicCode("JSON serialization may require dynamic code generation which is not compatible with AOT compilation.")]
public static IServiceCollection AddEventSerializer(this IServiceCollection services)

Parameters

services IServiceCollection

The service collection.

Returns

IServiceCollection

The service collection for method chaining.

Remarks

Registers JsonEventSerializer as IEventSerializer by default. JSON provides zero-ceremony serialization that works with any event type.

For binary serialization (MemoryPack, etc.), use the opt-in provider packages: builder.UseMemoryPackEventSerializer().

AddPluggableSerialization(IServiceCollection)

Adds pluggable serialization services to the service collection.

public static IServiceCollection AddPluggableSerialization(this IServiceCollection services)

Parameters

services IServiceCollection

The service collection.

Returns

IServiceCollection

The service collection for method chaining.

Remarks

This method registers:

By default, JSON (System.Text.Json) is the current serializer. MemoryPack and other binary formats are opt-in via provider packages. Use WithSerialization(IDispatchBuilder, Action<ISerializationBuilder>) to customize this behavior.

AddPluggableSerializer(IServiceCollection, byte, ISerializer)

Registers a pluggable serializer with the service collection.

public static IServiceCollection AddPluggableSerializer(this IServiceCollection services, byte id, ISerializer serializer)

Parameters

services IServiceCollection

The service collection.

id byte

The serializer ID.

serializer ISerializer

The serializer implementation.

Returns

IServiceCollection

The service collection for method chaining.

Remarks

This method is typically used by serializer packages (e.g., Excalibur.Dispatch.Serialization.MemoryPack) to register their implementations during service configuration.

The serializer will be registered when the ISerializerRegistry is first resolved.

AddPluggableSerializer(IServiceCollection, byte, ISerializer, bool)

Registers a pluggable serializer with the service collection and sets it as current.

public static IServiceCollection AddPluggableSerializer(this IServiceCollection services, byte id, ISerializer serializer, bool setAsCurrent)

Parameters

services IServiceCollection

The service collection.

id byte

The serializer ID.

serializer ISerializer

The serializer implementation.

setAsCurrent bool

Whether to set this serializer as the current serializer.

Returns

IServiceCollection

The service collection for method chaining.

WithSerialization(IDispatchBuilder, Action<ISerializationBuilder>)

Configures serialization for internal persistence using ISerializationBuilder.

public static IDispatchBuilder WithSerialization(this IDispatchBuilder builder, Action<ISerializationBuilder> configure)

Parameters

builder IDispatchBuilder

The dispatch builder.

configure Action<ISerializationBuilder>

Configuration action for the serialization builder.

Returns

IDispatchBuilder

The dispatch builder for method chaining.

Remarks

The ISerializationBuilder has 3 core methods; format-specific convenience methods are available as extension methods in SerializationBuilderExtensions.