Guacamole.Mediator 1.6.0

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

Guacamole.Mediator

A minimal mediator for .NET that dispatches requests to scoped handlers resolved from the DI container.

Install

dotnet add package Guacamole.Mediator

Register

// Scan a single assembly
builder.Services.AddMediator(typeof(GetUserHandler).Assembly);

// Scan multiple assemblies
builder.Services.AddMediator(
    typeof(GetUserHandler).Assembly,
    typeof(OrderHandler).Assembly);

All IRequestHandler<TRequest, TResponse> and IRequestHandler<TRequest> implementations found in the scanned assemblies are registered as scoped services automatically. IMediator is also registered as scoped.

Define a request and handler

// Request with response
public record GetUserQuery(Guid Id) : IRequest<UserDto>;

public class GetUserHandler(IUserRepository repo) : IRequestHandler<GetUserQuery, UserDto>
{
    public async Task<UserDto> Handle(GetUserQuery request, CancellationToken ct)
        => await repo.GetByIdAsync(request.Id, ct);
}

// Fire-and-forget
public record DeleteUserCommand(Guid Id) : IRequest;

public class DeleteUserHandler(IUserRepository repo) : IRequestHandler<DeleteUserCommand>
{
    public async Task Handle(DeleteUserCommand request, CancellationToken ct)
        => await repo.DeleteAsync(request.Id, ct);
}

Send

// Inject IMediator
var user = await mediator.Send(new GetUserQuery(id), ct);  // returns TResponse
await mediator.Send(new DeleteUserCommand(id), ct);        // fire-and-forget

Error handling

If no handler is registered for a request type, Send throws InvalidOperationException with a diagnostic message naming the missing handler interface:

No handler registered for request type 'GetUserQuery'.
Ensure you called AddMediator() and the handler implements IRequestHandler<GetUserQuery, UserDto>.
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
1.6.0 220 6/17/2026
1.5.9 97 8/17/2026
1.5.8 105 8/17/2026
1.5.7 99 8/17/2026
1.5.6 104 8/17/2026
1.5.5 102 8/17/2026
1.5.4 123 6/17/2026
1.5.3-alpha.6 76 6/17/2026
1.5.2-alpha.5 72 6/17/2026
1.5.0 124 6/1/2026
1.5.0-alpha.4 86 6/17/2026
1.5.0-alpha.2 78 6/16/2026
1.4.0 116 6/1/2026
1.2.0 124 5/27/2026
1.1.0 117 5/27/2026
1.0.0 112 5/27/2026