ChitMeo 1.0.0
dotnet add package ChitMeo --version 1.0.0
NuGet\Install-Package ChitMeo -Version 1.0.0
<PackageReference Include="ChitMeo" Version="1.0.0" />
<PackageVersion Include="ChitMeo" Version="1.0.0" />
<PackageReference Include="ChitMeo" />
paket add ChitMeo --version 1.0.0
#r "nuget: ChitMeo, 1.0.0"
#:package ChitMeo@1.0.0
#addin nuget:?package=ChitMeo&version=1.0.0
#tool nuget:?package=ChitMeo&version=1.0.0
ChitMeoMediator
ChitMeoMediator - Simple mediator for modular .NET applications. ChitMeoMediator is a lightweight mediator implementation for .NET designed to be simple, dependency-free, and easy to extend. It implements the Mediator pattern commonly used in CQRS architectures while keeping the codebase minimal and transparent.
Features
- Lightweight and dependency-free
- Automatic handler discovery
- Seamless integration with
Microsoft.Extensions.DependencyInjection - Designed for modular monolith architectures
- Minimal reflection usage
- Easy to extend with pipelines and behaviors
Installation
Install from NuGet:
dotnet add package ChitMeoMediator
Quick Start
1. Register ChitMeoMediator
builder.Services.AddMediator();
AddMediator() automatically scans assemblies containing .Module. in their name and registers request handlers.
2. Create a Request
public class Ping : IRequest<string>
{
}
3. Create a Handler
public class PingHandler : IRequestHandler<Ping, string>
{
public Task<string> HandleAsync(Ping request, CancellationToken cancellationToken)
{
return Task.FromResult("Pong");
}
}
4. Send Request
var result = await mediator.SendAsync(new Ping());
Console.WriteLine(result); // Pong
Interfaces
IRequest
Represents a request expecting a response.
public interface IRequest<TResponse>
{
}
IRequestHandler
Handles a specific request.
public interface IRequestHandler<TRequest, TResponse>
{
Task<TResponse> HandleAsync(TRequest request, CancellationToken cancellationToken);
}
IMediator
Sends requests to their handlers.
public interface IMediator
{
Task<TResponse> SendAsync<TResponse>(
IRequest<TResponse> request,
CancellationToken cancellationToken = default);
}
Assembly Scanning
ChitMeoMediator automatically discovers handlers in assemblies that match:
*.Module.*.dll
Example:
MyApp.Module.Users
MyApp.Module.Orders
This allows a modular monolith architecture where each module contains its own handlers.
Performance
ChitMeoMediator focuses on simplicity while maintaining excellent performance.
Example benchmark:
| Method | Mean |
|---|---|
| Direct call | ~21 ns |
| ChitMeoMediator | ~135 ns |
The overhead is minimal and suitable for most applications.
Roadmap
Possible future features:
- Pipeline behaviors
- Notification handlers
- Source generator optimization
- Request caching
- Transaction pipeline
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|