Loosely Coupled by Default
Every interaction flows through messages, so components never call each other directly. Change, replace, or remove any handler without ripple effects across your codebase.
Appearance
Easy to maintain, easy to test, and blazingly fast โ a convention-based mediator powered by source generators and interceptors
Comprehensive diagnostics catch errors early. Short, simple call stacks with minimal indirection make debugging straightforward.
Create a simple handler by following naming conventions:
public record Ping(string Text);โpublic class PingHandler{ public string Handle(Ping msg) => $"Pong: {msg.Text}";}
Register the mediator and use it:
// Program.csservices.AddMediator();โ// Usagevar reply = await mediator.InvokeAsync<string>(new Ping("Hello"));// Output: "Pong: Hello"
Turn your message handlers into API endpoints automatically:
app.MapMediatorEndpoints();// That's it โ routes, methods, and parameter binding are all generated for you.