Mando 2.0.0

dotnet add package Mando --version 2.0.0
                    
NuGet\Install-Package Mando -Version 2.0.0
                    
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="Mando" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mando" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Mando" />
                    
Project file
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 Mando --version 2.0.0
                    
#r "nuget: Mando, 2.0.0"
                    
#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 Mando@2.0.0
                    
#: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=Mando&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Mando&version=2.0.0
                    
Install as a Cake Tool

Mando

A super lightweight and free alternative to libraries that provide decoupled, in-process communication.

Mando Logo

Build and Test GitHub License GitHub Release NuGet Version NuGet Downloads


Usage

You can use the package directly or fork this repo and create your own, custom implementation.

Installation

The easiest way to add Mando to your project via NuGet.

Features

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:

Single command, single handler.

internal sealed MyCustomCommand : ICommand;

internal sealed MyCustomCommandHandler : ICommandHandler<MyCustomCommand>
{
    public Task Execute(MyCustomCommand command)
    {
        // Your magic here!
    }
}

Single command, multiple handlers.

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!
    }
}

Multiple commands, single handler

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!
    }
}

Command with a result

internal sealed record GetAnswerCommand : ICommand<int>;

internal sealed class GetAnswerCommandHandler : ICommandHandler<GetAnswerCommand, int>
{
    public Task<int> Execute(GetAnswerCommand command)
    {
        return Task.FromResult(42);
    }
}

// Dispatch and receive the result
int answer = await dispatcher.Dispatch(new GetAnswerCommand());

Events (publish / subscribe)

Events are one-way notifications. A publisher fires an event and every subscriber for that event type is notified, staying fully decoupled from each other.

Subscriber registered via Dependency Injection:

internal sealed record OrderPlaced(int OrderId) : IEvent;

// Discovered and registered automatically by AddMando
internal sealed class OrderNotifier : IEventSubscriber<OrderPlaced>
{
    public Task Handle(OrderPlaced @event)
    {
        Console.WriteLine($"Order \"{@event.OrderId}\" has been placed!");
        return Task.CompletedTask;
    }
}

// Publish through IEventBus. All subscribers of OrderPlaced are notified.
await eventBus.Publish(new OrderPlaced(1));

Subscribe at runtime, anywhere:

// Subscribe at any point during execution, not only during DI setup.
// Dispose the returned handle to remove the subscription.
IEventSubscription subscription = eventBus.Subscribe<OrderPlaced>(@event =>
{
    Console.WriteLine($"Order \"{@event.OrderId}\" has been placed!");
    return Task.CompletedTask;
});

await eventBus.Publish(new OrderPlaced(1)); // handler fires

subscription.Dispose(); // handler no longer fires

Runtime subscriptions run alongside DI-registered subscribers. Subscribing and disposing are thread-safe, and safe to call concurrently with Publish.

Dependency Injection

services.AddMando(Assembly.GetExecutingAssembly()))

This registers

  • ICommandHandler<TCommand> and ICommandHandler<TCommand, TResult> : All implementations are registered as Scoped
  • IDispatcher as Scoped
  • IEventSubscriber<TEvent> : All implementations are registered as Singleton (one instance shared across all subscribed events)
  • IEventBus as Singleton

Usage

internal sealed class Application(IDispatcher dispatcher, IEventBus eventBus) : IApplication
{
    public async Task RunAsync()
    {
        await dispatcher.Dispatch(new DoSomethingCommand());
        await eventBus.Publish(new OrderPlaced(1));
    }
}

Checkout Mando.Example for a working example.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 347 8/12/2026
1.0.1 103 7/31/2026
1.0.0 102 7/31/2026
0.4.1 111 4/26/2026
0.4.0 103 4/26/2026
0.3.1 129 3/12/2026
0.3.0 341 9/17/2025
0.2.0 155 9/6/2025
0.1.2 209 9/1/2025
0.1.1 207 9/1/2025
0.1.0 212 8/31/2025