Mecesoft.Mediator 1.0.0

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

Mecesoft.Mediator

Package version: 1.0.0 (not yet published on NuGet)

Supports .NET 8 and .NET 10. Includes optimized request dispatch, improved pipeline execution, and configurable notification publishing.

Mecesoft.Mediator is a lightweight, dependency-injection-friendly mediator library for .NET. It supports requests, notifications, dependency-injection scopes, and ordered pipeline behaviors without an external mediator dependency.

  • GitHub repository
  • NuGet package (draft; version 1.0.0 is not published yet): https://www.nuget.org/packages/Mecesoft.Mediator

Installation

Version 1.0.0 is not published yet. The intended installation command after publication is:

dotnet add package Mecesoft.Mediator

Registration

Register handlers from one or more assemblies and, optionally, open pipeline behaviors:

using Mecesoft.Mediator;

builder.Services.AddMediator(options =>
{
    options.AddRegisterAssemblies(typeof(Program).Assembly);
    options.AddOpenBehavior(typeof(LoggingBehavior<,>));
});

ISender and discovered handlers are registered as transient services. Resolve ISender from the request scope so handlers can safely consume scoped services such as DbContext.

Requests

Requests with a response implement IRequest<TResponse>:

public sealed record GetUser(Guid Id) : IRequest<User>;

public sealed class GetUserHandler(IUserRepository repository)
    : IRequestHandler<GetUser, User>
{
    public Task<User> Handle(
        GetUser request,
        CancellationToken cancellationToken) =>
        repository.GetAsync(request.Id, cancellationToken);
}

User user = await sender.Send(new GetUser(id), cancellationToken);

Void requests implement IRequest and use IRequestHandler<TRequest>. Cancellation tokens are passed to handlers and pipeline behaviors unchanged.

Pipeline behaviors

For response requests, a pipeline behavior declares both the request and response types:

public sealed class LoggingBehavior<TRequest, TResponse>
    : IPipelineBehavior<TRequest, TResponse>
    where TRequest : IRequest<TResponse>
{
    public async Task<TResponse> Handle(
        TRequest request,
        RequestHandlerDelegate<TResponse> next,
        CancellationToken cancellationToken = default)
    {
        return await next();
    }
}

Void requests use IPipelineBehavior<TRequest> and RequestHandlerDelegate. Pipeline behaviors execute in registration order and may short-circuit without constructing the request handler.

Notifications

Notification handlers run concurrently by default. Applications whose handlers share scoped dependencies that are not concurrency-safe can opt into sequential execution during registration:

builder.Services.AddMediator(options =>
{
    options.AddRegisterAssemblies(typeof(Program).Assembly);
    options.PublishNotificationsConcurrently = false;
});

Notification and request handler failures propagate to the caller without being wrapped in reflection exceptions.

API

The 1.0.0 public API uses:

IRequest, IRequest<TResponse>, IRequestHandler, ISender, Sender, INotification, INotificationHandler, IPipelineBehavior, AddMediator, MediatorOptions, RequestHandlerDelegate, and MediatorOptions.PublishNotificationsConcurrently.

No legacy aliases are provided. Consumer code must use AddMediator, MediatorOptions, and RequestHandlerDelegate.

License

Mecesoft.Mediator is available under the MIT License.

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

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.0.0 110 10/23/2026

Initial release under the Mecesoft.Mediator identity.
           Public API: AddMediator, MediatorOptions, and RequestHandlerDelegate.
           Supports .NET 8 and .NET 10.