MDiator 0.0.13
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package MDiator --version 0.0.13
NuGet\Install-Package MDiator -Version 0.0.13
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MDiator" Version="0.0.13" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MDiator" Version="0.0.13" />
<PackageReference Include="MDiator" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MDiator --version 0.0.13
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MDiator, 0.0.13"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MDiator@0.0.13
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MDiator&version=0.0.13
#tool nuget:?package=MDiator&version=0.0.13
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MDiator ๐งฉ
MDiator is a lightweight, extensible in-process messaging library for .NET.
It provides clean abstractions for sending requests and publishing events using a mediator pattern โ without the bloat.
Inspired by MediatR, built for performance and clarity.
๐ Features
Send<TRequest>
: Handle a single request with a typed responsePublish<TEvent>
: Broadcast events to multiple handlers- Auto-registration of handlers via assembly scanning
- No reflection at runtime โ uses compiled delegates
- Minimal dependencies
๐ฆ Installation
Add it to your project (once published to NuGet):
dotnet add package MDiator
Register in Program.cs
services.AddMDiator(typeof(Program).Assembly);
๐งช Example Usage Define a Command
public class CreateUserCommand : IMDiatorRequest<string>
{
public string UserName { get; set; }
}
public class CreateUserHandler : IMDiatorHandler<CreateUserCommand, string>
{
public Task<string> Handle(CreateUserCommand command)
=> Task.FromResult($"Created user: {command.UserName}");
}
var result = await mediator.Send(new CreateUserCommand { UserName = "Mostafa" });
๐ฃ Event Example
public class OrderCreatedEvent : IMDiatorEvent
{
public int OrderId { get; set; }
}
public class NotifyTeamHandler : IMDiatorEventHandler<OrderCreatedEvent>
{
public Task Handle(OrderCreatedEvent e)
{
Console.WriteLine($"Notify team about order {e.OrderId}");
return Task.CompletedTask;
}
}
await mediator.Publish(new OrderCreatedEvent { OrderId = 123 });
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.