Class SimpleMediatorConfiguration
- Namespace
- SimpleMediator
- Assembly
- SimpleMediator.dll
Configures discovery and additional mediator components.
public sealed class SimpleMediatorConfiguration
- Inheritance
-
SimpleMediatorConfiguration
- Inherited Members
Remarks
Used by AddSimpleMediator(IServiceCollection, Action<SimpleMediatorConfiguration>?, params Assembly[]) to fine-tune automatic registrations.
Properties
HandlerLifetime
Lifetime applied to handlers registered through scanning.
public ServiceLifetime HandlerLifetime { get; }
Property Value
NotificationDispatch
Gets the notification dispatch configuration options.
public NotificationDispatchOptions NotificationDispatch { get; }
Property Value
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
pipelineBehaviorTypeType
Returns
AddPipelineBehavior<TBehavior>()
Adds a generic behavior to the pipeline.
public SimpleMediatorConfiguration AddPipelineBehavior<TBehavior>() where TBehavior : class
Returns
Type Parameters
TBehavior
AddRequestPostProcessor(Type)
Adds a specific post-processor to the pipeline.
public SimpleMediatorConfiguration AddRequestPostProcessor(Type processorType)
Parameters
processorTypeType
Returns
AddRequestPostProcessor<TProcessor>()
Adds a generic post-processor to the pipeline.
public SimpleMediatorConfiguration AddRequestPostProcessor<TProcessor>() where TProcessor : class
Returns
Type Parameters
TProcessor
AddRequestPreProcessor(Type)
Adds a specific pre-processor to the pipeline.
public SimpleMediatorConfiguration AddRequestPreProcessor(Type processorType)
Parameters
processorTypeType
Returns
AddRequestPreProcessor<TProcessor>()
Adds a generic pre-processor to the pipeline.
public SimpleMediatorConfiguration AddRequestPreProcessor<TProcessor>() where TProcessor : class
Returns
Type Parameters
TProcessor
RegisterServicesFromAssemblies(params Assembly[])
Adds multiple assemblies to the scan list.
public SimpleMediatorConfiguration RegisterServicesFromAssemblies(params Assembly[] assemblies)
Parameters
assembliesAssembly[]
Returns
RegisterServicesFromAssembly(Assembly)
Adds an assembly to scan for handlers, behaviors, and processors.
public SimpleMediatorConfiguration RegisterServicesFromAssembly(Assembly assembly)
Parameters
assemblyAssembly
Returns
RegisterServicesFromAssemblyContaining<T>()
Adds the assembly that contains the specified type.
public SimpleMediatorConfiguration RegisterServicesFromAssemblyContaining<T>()
Returns
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
strategyNotificationDispatchStrategyThe dispatch strategy to use. Default is Parallel.
maxDegreeOfParallelismintMaximum 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
lifetimeServiceLifetime