Bsft.Mediator 2.2.0

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

Bsft.Mediator

The mediator implementation of the Bsft.Mediator family: the dispatcher that resolves a command, query or notification to its handler, the pipeline that wraps it, and the four shipped behaviors — logging, tracing, transactions and validation.

Install

dotnet add package Bsft.Mediator

Requires Bsft.Mediator.Abstractions (pulled transitively), Bsft.Core for the startup-validator seam and Bsft.Instrumentation for the instrumentation source. Nothing here needs ASP.NET Core: a worker or a console tool dispatches through it unchanged.

Register

services.AddBsftMediator(mediator =>
{
    mediator.RegisterServicesFromAssembly(typeof(Program).Assembly);
    mediator.EnableTracing();
    mediator.AddBehavior(typeof(LoggingBehavior<,>));
});

Nothing else is required. AddBsftMediator takes a MediatorConfiguration rather than an options type, because what it configures is which handlers and behaviors exist — a container decision, not a setting a host would bind from a configuration file. Behavior order is registration order, innermost last, so anything that must run on every dispatch (authorization above all) is registered before anything that may short-circuit it, such as Bsft.Caching's behavior.

UseDefaults() takes that decision out of the host's hands: it registers the cross-cutting behaviors of every behavior package the application references — tracing, authorization, validation, audit, retry, transaction, caching — in the order the framework fixes, and applies that order when the pipeline is folded, so it holds however the packages were registered. One behavior is dropped with SuppressDefaultBehavior(MediatorDefaults.Caching); the whole chain stays the host's by omitting UseDefaults().

Configure

Option Default Effect
MediatorConfiguration.RegisterServicesFromAssembly(assembly) none Registers every ICommandHandler, IQueryHandler and INotificationHandler the assembly declares.
MediatorConfiguration.AddBehavior(type) none Appends an open-generic IPipelineBehavior<,> to the pipeline, innermost last.
MediatorConfiguration.EnableTracing() off Adds TracingBehavior, which opens an activity on the Bsft.Mediator source per dispatch.
MediatorConfiguration.ForwardNotifications() off Publishes every notification onto the registered INotificationForwarder; Bsft.Mediator.EventAggregator supplies one.
MediatorConfiguration.UseDefaults() off Registers the canonical cross-cutting chain from the referenced behavior packages, in the framework's order. Implies EnableTracing().
MediatorConfiguration.SuppressDefaultBehavior(name) none Drops one behavior from that chain; a name matching none throws.

Validation: MediatorStartupValidator runs through Bsft.Core's IStartupValidator and fails the host when a registered behavior cannot be constructed, when a request has no handler, or when it has more than one — before the first request rather than on the first dispatch of the affected message. A second handler is as quiet a mistake as a missing one: dispatch resolves a single service, so the container decides which of them runs and the other never does. A command without a result is allowed one handler of each shape, ICommandHandler<T> and ICommandHandler<T, Unit>, because dispatch prefers the first and only falls back to the second.

Extend

IPipelineBehavior<TRequest, TResponse> is the extension point that matters: everything cross-cutting in this framework — caching, resilience, auditing, the four behaviors here — is one. It is declared in Bsft.Mediator.Abstractions with the rest of the contract, so a behavior can be written without referencing this package.

IRequestMetadataProvider is the seam a behavior reads the concrete request type and its attributes through, registered here as a singleton and declared in the abstractions package so a behavior satellite can take it without taking this one. It is a cache rather than a policy, so the registration is TryAdd and a host that supplies its own provider keeps it. The shipped RequestMetadataProvider is public, so that provider can decorate it rather than replace it outright.

IMediator itself is replaceable but rarely should be: Mediator is sealed, and a wrapper that adds behaviour belongs in the pipeline instead. The four shipped behaviors are sealed for the same reason — compose them, do not inherit them. IMediatorTelemetry is the seam for emitting somewhere other than the shipped ActivitySource. Both registrations are TryAdd, so a host that registers its own keeps it whether it did so before or after AddBsftMediator.

Documentation

Topic page: docs/mediator.md. Conventions: docs/package-conventions.md.

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 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 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 (1)

Showing the top 1 NuGet packages that depend on Bsft.Mediator:

Package Downloads
Bsft.Testing

BSFT Framework test harnesses and test doubles for integration, mediator, and saga tests

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.0 168 10/23/2026
2.1.0 145 9/28/2026