Skip to content

Decision Matrix ​

Use this matrix to quickly choose the right contract and dispatch call.

Message Type Matrix ​

You NeedDefine Contract AsImplement HandlerCallHandler Count
One response valueIRequest<TResponse>IRequestHandler<TRequest, TResponse>Send(...)Exactly one
No response valueIRequestIRequestHandler<TRequest>Send(...)Exactly one
Fan-out eventINotificationINotificationHandler<TNotification>Publish(...)Zero to many
Async stream of valuesIStreamRequest<TResponse>IStreamRequestHandler<TRequest, TResponse>CreateStream(...)Exactly one

Cross-Cutting Matrix ​

ConcernExtension PointApplies ToCan Short-Circuit
Validation before handlingIRequestPreProcessor<TRequest>Requests and streams (IBaseRequest)No
Around request executionIPipelineBehavior<TRequest, TResponse>Request/response and void requestsYes
Around stream executionIStreamPipelineBehavior<TRequest, TResponse>Stream requestsYes
Post-handle side effectsIRequestPostProcessor<TRequest, TResponse>Request/response and void requestsNo
Recover from known exceptionsIRequestExceptionHandler<TRequest, TResponse, TException>Request/response and void requestsYes (SetHandled)
Side effects on unhandled exceptionsIRequestExceptionAction<TRequest, TException>Request/response and void requestsNo
Recover from stream exceptionsIStreamRequestExceptionHandler<TRequest, TResponse, TException>Stream requestsYes (SetHandled)

Notification Delivery Matrix ​

StrategyConfigureBest ForTradeoff
SequentialUseNotificationPublisherStrategy(Sequential)Deterministic order and simpler tracingLower throughput
ParallelUseNotificationPublisherStrategy(Parallel)Faster fan-out when handlers are independentConcurrency and aggregate exception handling

Package Selection Matrix ​

Project TypePackage
Contracts-only shared libraryNerdigy.Mediator.Contracts
Application runtime without DI helperNerdigy.Mediator + Nerdigy.Mediator.Contracts
Typical app with IServiceCollectionNerdigy.Mediator.DependencyInjection (transitively includes runtime + contracts)

LLM Prompt Helper ​

Use this decision stub in prompts:

text
Pick mediator contract using these rules:
- If exactly one response is needed: IRequest<TResponse> + Send
- If no response is needed: IRequest + Send
- If one-to-many event fan-out is needed: INotification + Publish
- If progressive results are needed: IStreamRequest<TResponse> + CreateStream

Registration Quick Reference ​

csharp
services.AddMediator(options =>
{
    options.RegisterServicesFromAssemblyContaining<Program>();
    options.UseNotificationPublisherStrategy(
        NerdigyMediatorNotificationPublisherStrategy.Sequential);
    options.AddOpenBehavior(typeof(LoggingBehavior<,>));
});

Mediator runtime for .NET