Common.Mediator
0.0.1
dotnet add package Common.Mediator --version 0.0.1
NuGet\Install-Package Common.Mediator -Version 0.0.1
<PackageReference Include="Common.Mediator" Version="0.0.1" />
<PackageVersion Include="Common.Mediator" Version="0.0.1" />
<PackageReference Include="Common.Mediator" />
paket add Common.Mediator --version 0.0.1
#r "nuget: Common.Mediator, 0.0.1"
#:package Common.Mediator@0.0.1
#addin nuget:?package=Common.Mediator&version=0.0.1
#tool nuget:?package=Common.Mediator&version=0.0.1
Common.Mediator
A lightweight, high-performance mediator implementation for .NET, providing in-process messaging with support for requests, commands, queries, notifications, and pipeline behaviors.
Acknowledgment
The API design of this library (interface names and contracts) is inspired by MediatR by Jimmy Bogard. This is an independent implementation — no source code was copied from MediatR. The internal implementation uses compiled expression trees for handler dispatch, which differs from MediatR's approach.
This project is licensed under the Apache License 2.0. See LICENSE.md for details.
Features
- Request/Response — send a request and get a typed response via
ISender - Commands & Queries — CQRS marker interfaces (
ICommand<TResult>,IQuery<TResult>) - Void Requests — fire-and-forget requests returning
Unit - Notifications — publish to multiple handlers via
IPublisher - Pipeline Behaviors — middleware pipeline for cross-cutting concerns (logging, validation, etc.)
- Assembly Scanning — automatic handler registration from assemblies
- Zero External Dependencies — only requires
Microsoft.Extensions.DependencyInjection
Installation
dotnet add package Common.Mediator
Quick Start
Register services
services.AddMediator(cfg =>
{
cfg.RegisterServicesFromAssembly(typeof(MyHandler).Assembly);
cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>));
});
Define a request and handler
public record GetUserQuery(int Id) : IQuery<UserDto>;
public class GetUserHandler : IRequestHandler<GetUserQuery, UserDto>
{
public Task<UserDto> Handle(GetUserQuery request, CancellationToken cancellationToken)
{
// handle logic
}
}
Send a request
var user = await sender.Send(new GetUserQuery(42));
Publish a notification
public record UserCreated(int UserId) : INotification;
await publisher.Publish(new UserCreated(42));
License
This project is licensed under the Apache License 2.0. See LICENSE.md for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Common.Mediator:
| Package | Downloads |
|---|---|
|
Common.All
Combined package containing Common.Mediator, Common.Model, and Common.Repository libraries |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1 | 92 | 2/18/2026 |