Mediator.Lite
0.0.6
See the version list below for details.
dotnet add package Mediator.Lite --version 0.0.6
NuGet\Install-Package Mediator.Lite -Version 0.0.6
<PackageReference Include="Mediator.Lite" Version="0.0.6" />
<PackageVersion Include="Mediator.Lite" Version="0.0.6" />
<PackageReference Include="Mediator.Lite" />
paket add Mediator.Lite --version 0.0.6
#r "nuget: Mediator.Lite, 0.0.6"
#:package Mediator.Lite@0.0.6
#addin nuget:?package=Mediator.Lite&version=0.0.6
#tool nuget:?package=Mediator.Lite&version=0.0.6
Mediator.Lite
Mediator.Lite - Lightweight implementation of mediator for .NET
How to start
You need to install Nuget package: link
You can do this with the following commands:
Install-Package Mediator.Lite
Or with .NET CLI:
dotnet add package Mediator.Lite
How to use
To use this library you need to create an handlers by realizing IRequestHandler and register them in DI-container.
To create a handler for the specified command, you need to create the following classes:
public record YourCommand() : IRequest;
public class YourCommandHandler : IRequestHandler<YourCommand>
{
public Task Handle(YourCommand request, CancellationToken cancellationToken)
{
// Implementation...
}
}
Or if you need to return any response from handlers, you need to specify the response like this:
public record YourCommandResponse();
public record YourCommand() : IRequest<YourCommandResponse>;
public class YourCommandHandler : IRequestHandler<YourCommand, YourCommandResponse>
{
public Task<YourCommandResponse> Handle(YourCommand request, CancellationToken cancellationToken)
{
// Implementation...
}
}
Then you need to register handlers through this extension method for IServiceCollection and specifying assembly to search:
services.AddMediator(typeof(YourCommandHandler).Assembly);
When the AddMediator() method is called, it registers the Mediator class for dependency resolving and looks for handler classes implementing the IRequestHandler interface (both IRequestHandler<> that does not return a response and IRequestHandler<,> that does return a response) in the specified assembly and registers them as dependencies.
A few words
This library does not pretend to compete with the popular MediatR library, and does not try to borrow its code in any way. This library was made only for the purpose of using it in its own developments by its author (that is, me)
| 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 was computed. 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. |
-
net8.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.