Mecesoft.MediatR 1.1.0

Suggested Alternatives

Mecesoft.Mediator

Additional Details

No Longer Maintained. Use Mecesoft.Mediator instead.

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

Mecesoft.MediatR

NuGet version

Mecesoft.MediatR is a lightweight, dependency-injection-friendly mediator library for .NET. It supports requests, notifications, dependency-injection scopes, and ordered pipeline behaviors without a dependency on the MediatR package.

Current version: 1.1.0

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

Installation

Install the latest published version from NuGet:

dotnet add package Mecesoft.MediatR

Registration

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

using Mecesoft.MediatR;

builder.Services.AddMediatR(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,
        RequesteHandlerDelete<TResponse> next,
        CancellationToken cancellationToken = default)
    {
        return await next();
    }
}

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

Notifications

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

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

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

Compatibility

The existing IRequest, IRequest<TResponse>, IRequestHandler, ISender, Sender, INotification, INotificationHandler, IPipelineBehavior, and AddMediatR APIs remain available. The legacy RequesteHandlerDelete delegate names are retained for source compatibility.

License

Mecesoft.MediatR 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.1.0 69 10/23/2026 1.1.0 is deprecated.
1.0.3 5,116 11/27/2025
1.0.2 223 11/27/2025
1.0.1 1,869 8/3/2025
1.0.0 559 8/3/2025

Added support for .NET 8 and .NET 10.
           Optimized request dispatch performance and reduced allocations.
           Improved pipeline execution with lazy handler resolution.
           Preserved backward-compatible concurrent notification publishing.
           Added regression tests and improved documentation.