Mecesoft.MediatR
1.1.0
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
<PackageReference Include="Mecesoft.MediatR" Version="1.1.0" />
<PackageVersion Include="Mecesoft.MediatR" Version="1.1.0" />
<PackageReference Include="Mecesoft.MediatR" />
paket add Mecesoft.MediatR --version 1.1.0
#r "nuget: Mecesoft.MediatR, 1.1.0"
#:package Mecesoft.MediatR@1.1.0
#addin nuget:?package=Mecesoft.MediatR&version=1.1.0
#tool nuget:?package=Mecesoft.MediatR&version=1.1.0
Mecesoft.MediatR
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.
Project links
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 | Versions 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. |
-
net10.0
-
net8.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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.