BuildingBlocks.Mediator 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package BuildingBlocks.Mediator --version 1.0.1
                    
NuGet\Install-Package BuildingBlocks.Mediator -Version 1.0.1
                    
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="BuildingBlocks.Mediator" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BuildingBlocks.Mediator" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="BuildingBlocks.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 BuildingBlocks.Mediator --version 1.0.1
                    
#r "nuget: BuildingBlocks.Mediator, 1.0.1"
                    
#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 BuildingBlocks.Mediator@1.0.1
                    
#: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=BuildingBlocks.Mediator&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=BuildingBlocks.Mediator&version=1.0.1
                    
Install as a Cake Tool

BuildingBlocks.Mediator

CQRS-first Send + ordered pipeline mediator for .NET — ICommand / IQuery, ISender, host behaviors, optional telemetry, and startup handler validation.

NuGet License: MIT

Disclaimer: BuildingBlocks.Mediator is not designed to replace other mediator or messaging packages. It is a focused CQRS Send + pipeline building block for developers who want manual control over design patterns — registration, pipeline order, validation, telemetry, and host composition — rather than a batteries-included framework.

Requirements

  • .NET 8, .NET 9, or .NET 10 (net8.0 / net9.0 / net10.0)

Install

dotnet add package BuildingBlocks.Mediator

60-second quick start

services.AddMediator(cfg =>
{
    cfg.RegisterServicesFromAssemblyContaining<CreateOrderHandler>();
    cfg.AddOpenBehavior(typeof(ValidationBehavior<,>), order: 0);
    cfg.UseTelemetry();
    cfg.ValidateOnStartup = true;
});

public sealed record CreateOrder(string Product, int Qty) : ICommand<OrderId>;
public sealed class CreateOrderHandler : ICommandHandler<CreateOrder, OrderId>
{
    public Task<OrderId> Handle(CreateOrder command, CancellationToken ct)
        => Task.FromResult(new OrderId(Guid.NewGuid()));
}

// Prefer ISender at call sites
await sender.Send(new CreateOrder("SKU-1", 2), ct);

Features

  • CQRS markers: ICommand / ICommand<T> / IQuery<T> (no non-generic IQuery)
  • Void commands via ICommand : ICommand<Unit> (pipeline on the real type)
  • Ordered open/closed pipeline behaviors (AddOpenBehavior + optional order)
  • CommandPipelineBehavior / QueryPipelineBehavior filter bases
  • UseTelemetry — optional ActivitySource enrichment around Send (wraps pipeline + handler; not a behavior)
  • ValidateOnStartup — missing/duplicate handler checks at registration
  • HandlerLifetime — configure discovered handler lifetime (default Transient)
  • Exact-one handler resolution at Send (clear errors for missing/ambiguous handlers)
  • Open-generic handlers — scanned and closed on demand
  • Built-in assembly scanner — no Scrutor dependency

What it is not (v1)

  • No Publish / INotification
  • No streaming (CreateStream)
  • No exception handlers that replace results (faults rethrow)
  • No built-in FluentValidation or metrics (host AddOpenBehavior)
  • Not fully Native AOT (runtime MakeGenericType wrappers)
  • Open-generic handlers always resolve as Transient (ignore HandlerLifetime)

Docs

Demo host: FeatureFusion in the same repository.

License

MIT — Copyright (c) 2026 Mohammad Hasan Hosseini

Product 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 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 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.1.0 65 8/27/2026
1.0.1 98 8/10/2026
1.0.0 330 8/10/2026

See CHANGELOG.md in the repository for release notes.