Skip to content

Nerdigy.MediatorA mediator runtime for .NET 10

Dispatch requests, publish notifications, and stream responses through strongly-typed pipelines with expression-compiled caching that eliminates per-call reflection.

Minimal Example

csharp
// Define a request and its handler
public sealed record Ping(string Message) : IRequest<string>;

public sealed class PingHandler : IRequestHandler<Ping, string>
{
    public Task<string> Handle(Ping request, CancellationToken cancellationToken)
    {
        return Task.FromResult($"PONG: {request.Message}");
    }
}
csharp
// Register and dispatch
var services = new ServiceCollection();

services.AddMediator(options =>
{
    options.RegisterServicesFromAssemblyContaining<PingHandler>();
});

await using var provider = services.BuildServiceProvider();
var mediator = provider.GetRequiredService<IMediator>();

string response = await mediator.Send(new Ping("hello"));
// response == "PONG: hello"

Three Packages, Clear Boundaries

PackagePurpose
Nerdigy.Mediator.AbstractionsContracts only. IMediator, ISender, IPublisher, request/notification/stream interfaces, handler interfaces, pipeline and exception interfaces.
Nerdigy.MediatorRuntime. Dispatchers with expression-compiled caching, pipeline executors, exception processors, notification publishers. No DI framework dependency.
Nerdigy.Mediator.DependencyInjectionRegistration. AddMediator(...), assembly scanning, configurable service lifetimes, publisher strategy selection.

Next Steps

  • LLM Quickstart -- Copy-ready prompts and templates to generate production-ready handlers, behaviors, and streams with minimal iteration.
  • Decision Matrix -- Pick the right interface and dispatch pattern (Send, Publish, CreateStream) quickly.
  • Recipe Catalog -- Intent-based prompts for CQRS, domain events, streaming, validation, and exception recovery.
  • Getting Started -- Install packages, write your first handler, and dispatch a request in under five minutes.
  • Requests -- Request/response patterns, void requests, and handler conventions.
  • Pipelines -- Pre-processors, behaviors, post-processors, and execution order.
  • API Contracts -- Complete interface reference for every public type in the Abstractions package.

Mediator runtime for .NET