![]() |
VOOZH | about |
dotnet add package NetDevPack.SimpleMediator --version 1.2.0
NuGet\Install-Package NetDevPack.SimpleMediator -Version 1.2.0
<PackageReference Include="NetDevPack.SimpleMediator" Version="1.2.0" />
<PackageVersion Include="NetDevPack.SimpleMediator" Version="1.2.0" />Directory.Packages.props
<PackageReference Include="NetDevPack.SimpleMediator" />Project file
paket add NetDevPack.SimpleMediator --version 1.2.0
#r "nuget: NetDevPack.SimpleMediator, 1.2.0"
#:package NetDevPack.SimpleMediator@1.2.0
#addin nuget:?package=NetDevPack.SimpleMediator&version=1.2.0Install as a Cake Addin
#tool nuget:?package=NetDevPack.SimpleMediator&version=1.2.0Install as a Cake Tool
<img src="https://repository-images.githubusercontent.com/268701472/8bf84980-a6ce-11ea-83da-e2133c5a3a7a" alt=".NET DevPack" width="300px" />
A lightweight and straightforward mediator implementation for .NET applications, facilitating in-process messaging with minimal setup.
| Package | Version | Popularity |
|---|---|---|
NetDevPack.SimpleMediator |
👁 NuGet |
👁 Nuget |
If you found this project helpful or it assisted you in any way, please give it a star. It helps to support the project and the developers.
You can find complete example projects demonstrating how to use the SimpleMediator in the folder.
These include:
Send and PublishFeel free to explore and run them to see how the mediator works in different scenarios.
You can install the SimpleMediator package via NuGet Package Manager or the .NET CLI:
dotnet add package NetDevPack.SimpleMediator
To reference only the contracts for SimpleMediator, which includes:
IRequest (including generic variants)
INotification
This example demonstrates how to combine a Request (command/query) and a Notification (event) in a real-world use case.
✅ This scenario uses only
Microsoft.Extensions.DependencyInjection.Abstractionsfor DI registration — no framework-specific packages.
public class CreateCustomerCommand : IRequest<string>
{
public string Name { get; set; }
}
public class CustomerCreatedEvent : INotification
{
public Guid CustomerId { get; }
public CustomerCreatedEvent(Guid customerId)
{
CustomerId = customerId;
}
}
public class CreateCustomerHandler : IRequestHandler<CreateCustomerCommand, string>
{
private readonly IMediator _mediator;
public CreateCustomerHandler(IMediator mediator)
{
_mediator = mediator;
}
public async Task<string> Handle(CreateCustomerCommand request, CancellationToken cancellationToken)
{
var id = Guid.NewGuid();
// Simulate persistence...
// Publish event
await _mediator.Publish(new CustomerCreatedEvent(id), cancellationToken);
return $"Customer '{request.Name}' created with ID {id}";
}
}
public class SendWelcomeEmailHandler : INotificationHandler<CustomerCreatedEvent>
{
public Task Handle(CustomerCreatedEvent notification, CancellationToken cancellationToken)
{
Console.WriteLine($"Sending welcome email to customer {notification.CustomerId}");
return Task.CompletedTask;
}
}
You can register everything manually if you want full control:
services.AddSingleton<IMediator, Mediator>();
services.AddTransient<IRequestHandler<CreateCustomerCommand, string>, CreateCustomerHandler>();
services.AddTransient<INotificationHandler<CustomerCreatedEvent>, SendWelcomeEmailHandler>();
Or use assembly scanning with:
services.AddSimpleMediator();
public class CustomerAppService
{
private readonly IMediator _mediator;
public CustomerAppService(IMediator mediator)
{
_mediator = mediator;
}
public async Task<string> CreateCustomer(string name)
{
return await _mediator.Send(new CreateCustomerCommand { Name = name });
}
}
When the CreateCustomer method is called:
CreateCustomerHandler handles the requestCustomerCreatedEventSendWelcomeEmailHandler handles the eventThis structure cleanly separates commands (which change state and return a result) from notifications (which communicate to the rest of the system that something happened).
NetDevPack.SimpleMediator targets .NET Standard 2.1, and is compatible with .NET Core 3.1+, .NET 5+, .NET 6+, .NET 7+, .NET 8, and newer versions of the .NET runtime.
NetDevPack.SimpleMediator was developed by Eduardo Pires under the MIT license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 3 NuGet packages that depend on NetDevPack.SimpleMediator:
| Package | Downloads |
|---|---|
|
NetDevPack
.NET DevPack is a set of common implementations to help you implementing DDD, CQRS, Specification Patterns and another facilities |
|
|
AutoDomain.Modules.Core.Security
AutoDomain.Modules.Core.Security |
|
|
HybridRepoNet
HybridRepoNet is a robust and extensible repository implementation for .NET applications using PostgreSQL and Sql Server. It simplifies Create, Read, Update, and Delete (CRUD) operations while maintaining a clean architecture through the Unit of Work (UoW) pattern and Domain Events. |
Showing the top 1 popular GitHub repositories that depend on NetDevPack.SimpleMediator:
| Repository | Stars |
|---|---|
|
NetDevPack/NetDevPack
A smart set of common classes and implementations to improve your development productivity.
|