A super lightweight and free alternative to libraries that provide decoupled, in-process communication.
You can use the package directly or fork this repo and create your own, custom implementation.
The easiest way to add Mando to your project via NuGet.
The features of this library are limited by design, so that the library will be easier to extend if you decide to fork the repo and create a more custom implementation. The core features are, and will always be:
Code Example
internal sealed MyCustomCommand : ICommand;
internal sealed MyCustomCommandHandler : ICommandHandler<MyCustomCommand>
{
public Task Execute(MyCustomCommand command)
{
// Your magic here!
}
}Code Example
internal sealed MyCustomCommand : ICommand;
internal sealed MyCustomCommandHandlerOne : ICommandHandler<MyCustomCommand>
{
public Task Execute(MyCustomCommand command)
{
// Your magic here!
}
}
internal sealed MyCustomCommandHandlerTwo : ICommandHandler<MyCustomCommand>
{
public Task Execute(MyCustomCommand command)
{
// And some other magic here!
}
}Code Example
internal sealed MyCustomCommandOne : ICommand;
internal sealed MyCustomCommandTwo : ICommand;
internal sealed MyCustomCommandHandler :
ICommandHandler<MyCustomCommandOne>, ICommandHandler<MyCustomCommandTwo>
{
public Task Execute(MyCustomCommandOne command)
{
// Your magic here!
}
public Task Execute(MyCustomCommandTwo command)
{
// Even more magic here!
}
}services.AddMando(Assembly.GetExecutingAssembly()))This registers
ICommandHandler<TCommand>: All implementations are registered as ScopedIDispatcheras Scoped
internal sealed class Application(IDispatcher dispatcher) : IApplication
{
public Task RunAsync() => dispatcher.Dispatch(new DoSomethingCommand());
}Checkout Mando.Example for a working example.