Send commands and queries through a central mediator instead of calling services directly, reducing tight coupling in your .NET application.
Add cross-cutting behaviors like logging, validation, or performance tracing to all requests without modifying individual handler code.
Publish events that multiple handlers respond to independently, replacing direct method calls with a decoupled notification pattern.
Commercial use requires a paid license key from MediatR.io, open-source projects can use it free.
MediatR is a library for .NET applications that acts as an in-process message broker. Rather than having one part of your application call another part directly, you send a message through MediatR and it routes the message to the appropriate handler. This keeps different parts of your code from depending on each other directly. The library handles several types of messages. Requests are messages where you expect a single response back, useful for commands (do something and tell me the result) and queries (fetch something and return it). Notifications are messages that can be handled by multiple handlers at once, useful for events where several parts of the application need to react. It also supports streaming responses for scenarios where data comes back in chunks rather than all at once. MediatR integrates with the standard .NET dependency injection system and can be registered with a single call. It scans your assemblies for handler classes and wires them up automatically. You can also add pipeline behaviors, which are pieces of code that run before or after every request, useful for logging, validation, or performance measurement without adding that logic to your handler code. The library is installed via NuGet and has no external dependencies. Everything runs in-process, meaning messages stay within the same running application rather than being sent over a network. Starting from this version, a license key is required for commercial use. The key can be set during registration or directly on the Mediator class, and license keys are available at MediatR.io.
← luckypennysoftware on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.