Bondarukini.Mediator
10.0.0
dotnet add package Bondarukini.Mediator --version 10.0.0
NuGet\Install-Package Bondarukini.Mediator -Version 10.0.0
<PackageReference Include="Bondarukini.Mediator" Version="10.0.0" />
<PackageVersion Include="Bondarukini.Mediator" Version="10.0.0" />
<PackageReference Include="Bondarukini.Mediator" />
paket add Bondarukini.Mediator --version 10.0.0
#r "nuget: Bondarukini.Mediator, 10.0.0"
#:package Bondarukini.Mediator@10.0.0
#addin nuget:?package=Bondarukini.Mediator&version=10.0.0
#tool nuget:?package=Bondarukini.Mediator&version=10.0.0
Bondarukini.Mediator
A lightweight, dependency-free implementation of the Mediator pattern for .NET applications.
It allows clear separation between requests and their handlers and supports middleware-like pipeline behaviors.
β¨ Features
- Implements the Mediator pattern without any external dependencies
- Supports
IRequest<TResponse>andIRequestHandler<TRequest, TResponse> - Built-in support for Pipeline Behaviors
- Fully compatible with
Bondarukini.Validator - Extensible and easy to integrate into any .NET project
π Installation
dotnet add package Bondarukini.Mediator
π‘ Example Usage
1) Define a Request
public class CreateProductCommand : IRequest<Product>
{
public string Name { get; set; }
public decimal Price { get; set; }
}
2) Create a Handler
public class CreateProductHandler : IRequestHandler<CreateProductCommand, Product>
{
public Task<Product> Handle(CreateProductCommand request, CancellationToken cancellationToken)
{
var product = new Product { Name = request.Name, Price = request.Price };
return Task.FromResult(product);
}
}
3) Send the Request
var mediator = serviceProvider.GetRequiredService<IMediator>();
var result = await mediator.Send(new CreateProductCommand { Name = "Book", Price = 10m });
π§± Pipeline Behaviors
The mediator supports middleware-style pipeline behaviors, which wrap request handling.
You can use them for validation, transactions, logging, and exception handling.
Example registration:
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidatorBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(TransactionBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ExceptionBehaviour<,>));
π¦ Related Packages
| Package | Description |
|---|---|
| Bondarukini.Validator | FluentValidation-style rule system |
| Bondarukini.Mediator.Behaviors | Validation, Transaction, and Exception behaviors |
| Bondarukini.Mediator.DependencyInjection | Easy registration of Mediator and Validators in DI |
π§βπ» Author
Yurii Bondaruk
Clean, extensible, and minimalistic architecture tools for .NET πΊπ¦
| 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
- Bondarukini.Validator (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0-preview.5.25277.114)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bondarukini.Mediator:
| Package | Downloads |
|---|---|
|
Bondarukini.Mediator.DependencyInjection
Lightweight Mediator pattern implementation for .NET with no dependencies. |
GitHub repositories
This package is not used by any popular GitHub repositories.