RCommon.Mediator
2.4.1
dotnet add package RCommon.Mediator --version 2.4.1
NuGet\Install-Package RCommon.Mediator -Version 2.4.1
<PackageReference Include="RCommon.Mediator" Version="2.4.1" />
<PackageVersion Include="RCommon.Mediator" Version="2.4.1" />
<PackageReference Include="RCommon.Mediator" />
paket add RCommon.Mediator --version 2.4.1
#r "nuget: RCommon.Mediator, 2.4.1"
#:package RCommon.Mediator@2.4.1
#addin nuget:?package=RCommon.Mediator&version=2.4.1
#tool nuget:?package=RCommon.Mediator&version=2.4.1
RCommon.Mediator
Provides a mediator abstraction layer for RCommon that decouples application code from specific mediator libraries, enabling request/response dispatch and notification publishing through a uniform API.
Features
- Library-agnostic mediator API -- depend on
IMediatorServiceinstead of MediatR, Wolverine, or any other implementation - Request/response dispatch -- send requests to a single handler with or without a return value
- Notification publishing -- broadcast notifications to all registered subscribers
- Adapter pattern -- swap mediator implementations by changing only the
IMediatorAdapterregistration - Subscriber contracts --
IAppRequest,IAppRequest<TResponse>, andIAppNotificationmarker interfaces for message classification - Handler contracts --
IAppRequestHandler<TRequest>andIAppRequestHandler<TRequest, TResponse>for implementing handlers - Fluent builder API -- integrates with the
AddRCommon()builder pattern for clean DI configuration
Installation
dotnet add package RCommon.Mediator
Usage
using RCommon;
using RCommon.Mediator;
using RCommon.Mediator.Subscribers;
// Configure the mediator in your DI setup using a concrete adapter (e.g., MediatR)
services.AddRCommon(config =>
{
config.WithMediator<MediatRBuilder>(mediator =>
{
// Register handlers from your application assembly
mediator.AddHandlersFromAssemblyContainingType<CreateOrderHandler>();
});
});
// Define a request and handler
public class CreateOrderRequest : IAppRequest<OrderDto>
{
public string ProductName { get; set; }
public int Quantity { get; set; }
}
public class CreateOrderHandler : IAppRequestHandler<CreateOrderRequest, OrderDto>
{
public async Task<OrderDto> HandleAsync(CreateOrderRequest request,
CancellationToken cancellationToken = default)
{
// Handle the request and return a result
return new OrderDto { Id = Guid.NewGuid(), ProductName = request.ProductName };
}
}
// Consume the mediator from your application layer
public class OrderController
{
private readonly IMediatorService _mediator;
public OrderController(IMediatorService mediator)
{
_mediator = mediator;
}
public async Task<OrderDto> CreateOrder(CreateOrderRequest request)
{
return await _mediator.Send<CreateOrderRequest, OrderDto>(request);
}
public async Task NotifyOrderCreated(OrderCreatedNotification notification)
{
await _mediator.Publish(notification);
}
}
Key Types
| Type | Description |
|---|---|
IMediatorService |
Primary application-facing interface for sending requests and publishing notifications |
MediatorService |
Default implementation that delegates to an IMediatorAdapter |
IMediatorAdapter |
Adapter interface that bridges to a specific mediator library (e.g., MediatR) |
IMediatorBuilder |
Builder contract for configuring a mediator implementation within AddRCommon() |
IAppRequest |
Marker interface for requests dispatched to a single handler with no return value |
IAppRequest<TResponse> |
Marker interface for requests that return a response of type TResponse |
IAppNotification |
Marker interface for notifications broadcast to all registered subscribers |
IAppRequestHandler<TRequest> |
Handler contract for requests with no return value |
IAppRequestHandler<TRequest, TResponse> |
Handler contract for requests that produce a typed response |
Documentation
For full documentation, visit rcommon.com.
Related Packages
- RCommon.Core - Core abstractions and builder infrastructure
- RCommon.Mediatr - MediatR adapter implementation for
IMediatorAdapter
License
Licensed under the Apache License, Version 2.0.
| 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 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. |
-
net10.0
- RCommon.Core (>= 2.4.1)
-
net8.0
- RCommon.Core (>= 2.4.1)
-
net9.0
- RCommon.Core (>= 2.4.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on RCommon.Mediator:
| Package | Downloads |
|---|---|
|
RCommon.MediatR
A cohesive set of infrastructure libraries for dotnet that utilizes abstractions for event handling, persistence, unit of work, mediator, distributed messaging, event bus, CQRS, email, and more |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.4.1 | 101 | 2/18/2026 |
| 2.3.2-alpha.0.3 | 39 | 2/18/2026 |
| 2.3.2-alpha.0.2 | 30 | 2/18/2026 |
| 2.3.2-alpha.0.1 | 47 | 2/9/2026 |
| 2.3.1 | 105 | 2/5/2026 |
| 2.3.0 | 104 | 2/3/2026 |
| 2.2.2-alpha.0.1 | 387 | 12/11/2025 |
| 2.2.1-alpha.0.2 | 138 | 10/24/2025 |
| 2.2.1-alpha.0.1 | 128 | 10/24/2025 |
| 2.1.11-alpha.0.2 | 137 | 10/24/2025 |
| 2.1.11-alpha.0.1 | 95 | 7/18/2025 |
| 2.1.10 | 222 | 7/17/2025 |
| 2.1.9-alpha.0.1 | 141 | 7/17/2025 |
| 2.1.2.4 | 246 | 5/21/2025 |
| 2.1.2.3 | 213 | 5/1/2025 |
| 2.1.2.2 | 182 | 1/23/2025 |
| 2.1.2.1 | 165 | 1/17/2025 |
| 2.1.2 | 158 | 1/17/2025 |
| 2.1.1.4 | 172 | 1/7/2025 |
| 0.0.0-alpha.0 | 143 | 7/17/2025 |