Table of Contents

Class SimpleMediatorConfiguration

Namespace
SimpleMediator
Assembly
SimpleMediator.dll

Configures discovery and additional mediator components.

public sealed class SimpleMediatorConfiguration
Inheritance
SimpleMediatorConfiguration
Inherited Members

Remarks

Properties

HandlerLifetime

Lifetime applied to handlers registered through scanning.

public ServiceLifetime HandlerLifetime { get; }

Property Value

ServiceLifetime

NotificationDispatch

Gets the notification dispatch configuration options.

public NotificationDispatchOptions NotificationDispatch { get; }

Property Value

NotificationDispatchOptions

Remarks

Controls how notifications are dispatched to multiple handlers. By default, notifications are dispatched sequentially with fail-fast semantics.

Methods

AddPipelineBehavior(Type)

Adds a specific behavior to the pipeline.

public SimpleMediatorConfiguration AddPipelineBehavior(Type pipelineBehaviorType)

Parameters

pipelineBehaviorType Type

Returns

SimpleMediatorConfiguration

AddPipelineBehavior<TBehavior>()

Adds a generic behavior to the pipeline.

public SimpleMediatorConfiguration AddPipelineBehavior<TBehavior>() where TBehavior : class

Returns

SimpleMediatorConfiguration

Type Parameters

TBehavior

AddRequestPostProcessor(Type)

Adds a specific post-processor to the pipeline.

public SimpleMediatorConfiguration AddRequestPostProcessor(Type processorType)

Parameters

processorType Type

Returns

SimpleMediatorConfiguration

AddRequestPostProcessor<TProcessor>()

Adds a generic post-processor to the pipeline.

public SimpleMediatorConfiguration AddRequestPostProcessor<TProcessor>() where TProcessor : class

Returns

SimpleMediatorConfiguration

Type Parameters

TProcessor

AddRequestPreProcessor(Type)

Adds a specific pre-processor to the pipeline.

public SimpleMediatorConfiguration AddRequestPreProcessor(Type processorType)

Parameters

processorType Type

Returns

SimpleMediatorConfiguration

AddRequestPreProcessor<TProcessor>()

Adds a generic pre-processor to the pipeline.

public SimpleMediatorConfiguration AddRequestPreProcessor<TProcessor>() where TProcessor : class

Returns

SimpleMediatorConfiguration

Type Parameters

TProcessor

RegisterServicesFromAssemblies(params Assembly[])

Adds multiple assemblies to the scan list.

public SimpleMediatorConfiguration RegisterServicesFromAssemblies(params Assembly[] assemblies)

Parameters

assemblies Assembly[]

Returns

SimpleMediatorConfiguration

RegisterServicesFromAssembly(Assembly)

Adds an assembly to scan for handlers, behaviors, and processors.

public SimpleMediatorConfiguration RegisterServicesFromAssembly(Assembly assembly)

Parameters

assembly Assembly

Returns

SimpleMediatorConfiguration

RegisterServicesFromAssemblyContaining<T>()

Adds the assembly that contains the specified type.

public SimpleMediatorConfiguration RegisterServicesFromAssemblyContaining<T>()

Returns

SimpleMediatorConfiguration

Type Parameters

T

UseParallelNotificationDispatch(NotificationDispatchStrategy, int)

Configures parallel notification dispatch with the specified strategy.

public SimpleMediatorConfiguration UseParallelNotificationDispatch(NotificationDispatchStrategy strategy = NotificationDispatchStrategy.Parallel, int maxDegreeOfParallelism = -1)

Parameters

strategy NotificationDispatchStrategy

The dispatch strategy to use. Default is Parallel.

maxDegreeOfParallelism int

Maximum concurrent handlers. Default is -1 (uses processor count).

Returns

SimpleMediatorConfiguration

This configuration instance for chaining.

Examples

services.AddSimpleMediator(config =>
{
    config.UseParallelNotificationDispatch(
        NotificationDispatchStrategy.ParallelWhenAll,
        maxDegreeOfParallelism: 4);
});

WithHandlerLifetime(ServiceLifetime)

Sets the lifetime used for handlers registered through scanning.

public SimpleMediatorConfiguration WithHandlerLifetime(ServiceLifetime lifetime)

Parameters

lifetime ServiceLifetime

Returns

SimpleMediatorConfiguration