Skip to content

ForkForward.Mediator

In-process messaging for .NET: requests with one handler, notifications with many, and streams, with a pipeline around each call.

A community fork of MediatR

ForkForward.Mediator is a community fork of MediatR, created by Jimmy Bogard. It continues the last Apache-2.0-licensed MediatR code (12.5.0) under its own names: the package, the assemblies and the namespace are ForkForward.Mediator, and AddMediatR is AddMediator. Everything else behaves as in MediatR 12.5.0; Moving from MediatR 12 lists what differs.

The original project kept its documentation in a GitHub wiki, which is not part of the source code and today describes later versions under another licence. These pages were written for this fork from its code, its tests and its samples.

ForkForward is an independent project and is not affiliated with or endorsed by the original authors.

Install

dotnet add package ForkForward.Mediator

Version 13 runs on .NET 10 and .NET 11, with an asset for each. On .NET 11 it uses the runtime's own async support. It also works in applications published with Native AOT.

Applications on .NET 8, .NET 9 or .NET Framework use version 12.8, which also has a .NET Standard 2.0 asset: dotnet add package ForkForward.Mediator --version 12.8.0.

In one example

using ForkForward.Mediator;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddMediator(cfg => cfg.RegisterServicesFromAssemblyContaining<Ping>());
var mediator = services.BuildServiceProvider().GetRequiredService<IMediator>();

var reply = await mediator.Send(new Ping("Hello"));   // "Hello Pong"

public record Ping(string Message) : IRequest<string>;

public class PingHandler : IRequestHandler<Ping, string>
{
    public Task<string> Handle(Ping request, CancellationToken cancellationToken)
        => Task.FromResult($"{request.Message} Pong");
}

The pages

Examples

The samples folder has runnable programs for Microsoft.Extensions.DependencyInjection, ASP.NET Core, Autofac, DryIoc, Lamar, LightInject, SimpleInjector and Stashbox. The tests cover every feature described here.

Housekeeping

The releases are on NuGet; what changed in each is in the changelog.

Questions and bug reports go to the issues of this fork.