RCommon.MediatR 2.4.1

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

RCommon.MediatR

Integrates MediatR with RCommon's event handling and mediator systems, providing in-process event production, notification/request handling, and pipeline behaviors while programming against RCommon's abstractions.

Features

  • Publish events to all notification handlers using MediatR's fan-out (publish) semantics
  • Send events to a single request handler using MediatR's point-to-point (send) semantics
  • Bridge MediatR notifications and requests to RCommon's ISubscriber<T> and IAppRequestHandler<T> abstractions
  • Mediator adapter (MediatRAdapter) implementing IMediatorAdapter for request/response and notification patterns
  • Built-in pipeline behaviors for logging, validation, and unit of work
  • Support for both fire-and-forget requests and request/response patterns
  • Event subscription routing ensures events are delivered only to their configured producers

Installation

dotnet add package RCommon.MediatR

Usage

Configure MediatR for event handling:

using RCommon;
using RCommon.MediatR;

builder.Services.AddRCommon()
    .WithEventHandling<MediatREventHandlingBuilder>(eventHandling =>
    {
        // Register event subscribers
        eventHandling.AddSubscriber<OrderCreatedEvent, OrderCreatedEventHandler>();
    });

Configure MediatR as the mediator with requests, notifications, and pipeline behaviors:

using RCommon;
using RCommon.Mediator.MediatR;

builder.Services.AddRCommon()
    .WithMediator<MediatRBuilder>(mediator =>
    {
        // Register notifications (fan-out to all handlers)
        mediator.AddNotification<OrderShippedNotification, OrderShippedHandler>();

        // Register requests (single handler, fire-and-forget)
        mediator.AddRequest<CreateOrderCommand, CreateOrderCommandHandler>();

        // Register requests with responses
        mediator.AddRequest<GetOrderQuery, OrderDto, GetOrderQueryHandler>();

        // Add pipeline behaviors
        mediator.AddLoggingToRequestPipeline();
        mediator.AddValidationToRequestPipeline();
        mediator.AddUnitOfWorkToRequestPipeline();

        // Custom MediatR configuration
        mediator.Configure(cfg =>
        {
            cfg.RegisterServicesFromAssemblyContaining<Program>();
        });
    });

Key Types

Type Description
PublishWithMediatREventProducer IEventProducer that publishes events to all handlers via MediatR publish (fan-out)
SendWithMediatREventProducer IEventProducer that sends events to a single handler via MediatR send (point-to-point)
MediatRAdapter IMediatorAdapter implementation that wraps MediatR's IMediator for send/publish operations
MediatREventHandler<TEvent, TNotification> Bridges MediatR INotificationHandler to RCommon's ISubscriber<T> for event handling
MediatRNotificationHandler<T, TNotification> Bridges MediatR notifications to RCommon's ISubscriber<T> for app notifications
MediatRRequestHandler<T, TRequest> Bridges MediatR requests to RCommon's IAppRequestHandler<T>
MediatRRequestHandler<T, TRequest, TResponse> Bridges MediatR requests to RCommon's IAppRequestHandler<T, TResponse> for request/response
LoggingRequestBehavior<TRequest, TResponse> Pipeline behavior that logs command handling
ValidatorBehavior<TRequest, TResponse> Pipeline behavior that validates requests before handling
UnitOfWorkRequestBehavior<TRequest, TResponse> Pipeline behavior that wraps handlers in a transactional unit of work
MediatREventHandlingBuilder Builder for configuring MediatR-based event handling
MediatRBuilder Builder for configuring MediatR as the mediator implementation

Documentation

For full documentation, visit rcommon.com.

License

Licensed under the Apache License, Version 2.0.

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 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. 
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
2.4.1 77 2/18/2026
2.3.2-alpha.0.3 30 2/18/2026
2.3.2-alpha.0.2 34 2/18/2026
2.3.2-alpha.0.1 43 2/9/2026
2.3.1 87 2/5/2026
2.3.0 90 2/3/2026
2.2.2-alpha.0.1 390 12/11/2025
2.2.1-alpha.0.2 126 10/24/2025
2.2.1-alpha.0.1 131 10/24/2025
2.1.11-alpha.0.2 132 10/24/2025
2.1.11-alpha.0.1 101 7/18/2025
2.1.10 202 7/17/2025
2.1.9-alpha.0.1 146 7/17/2025
2.1.2.4 214 5/21/2025
2.1.2.3 201 5/1/2025
2.1.2.2 173 1/23/2025
2.1.2.1 150 1/17/2025
2.1.2 136 1/17/2025
2.1.1.4 164 1/7/2025
0.0.0-alpha.0 154 7/17/2025
Loading failed