MediatR 12.5.0
Prefix Reserveddotnet add package MediatR --version 12.5.0
NuGet\Install-Package MediatR -Version 12.5.0
<PackageReference Include="MediatR" Version="12.5.0" />
<PackageVersion Include="MediatR" Version="12.5.0" />
<PackageReference Include="MediatR" />
paket add MediatR --version 12.5.0
#r "nuget: MediatR, 12.5.0"
#addin nuget:?package=MediatR&version=12.5.0
#tool nuget:?package=MediatR&version=12.5.0
MediatR
Simple mediator implementation in .NET
In-process messaging with no dependencies.
Supports request/response, commands, queries, notifications and events, synchronous and async with intelligent dispatching via C# generic variance.
Examples in the wiki.
Installing MediatR
You should install MediatR with NuGet:
Install-Package MediatR
Or via the .NET Core command line interface:
dotnet add package MediatR
Either commands, from Package Manager Console or .NET Core CLI, will download and install MediatR and all required dependencies.
Using Contracts-Only Package
To reference only the contracts for MediatR, which includes:
IRequest
(including generic variants)INotification
IStreamRequest
Add a package reference to MediatR.Contracts
This package is useful in scenarios where your MediatR contracts are in a separate assembly/project from handlers. Example scenarios include:
- API contracts
- GRPC contracts
- Blazor
Registering with IServiceCollection
MediatR supports Microsoft.Extensions.DependencyInjection.Abstractions
directly. To register various MediatR services and handlers:
services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining<Startup>());
or with an assembly:
services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Startup).Assembly));
This registers:
IMediator
as transientISender
as transientIPublisher
as transientIRequestHandler<,>
concrete implementations as transientIRequestHandler<>
concrete implementations as transientINotificationHandler<>
concrete implementations as transientIStreamRequestHandler<>
concrete implementations as transientIRequestExceptionHandler<,,>
concrete implementations as transientIRequestExceptionAction<,>)
concrete implementations as transient
This also registers open generic implementations for:
INotificationHandler<>
IRequestExceptionHandler<,,>
IRequestExceptionAction<,>
To register behaviors, stream behaviors, pre/post processors:
services.AddMediatR(cfg => {
cfg.RegisterServicesFromAssembly(typeof(Startup).Assembly);
cfg.AddBehavior<PingPongBehavior>();
cfg.AddStreamBehavior<PingPongStreamBehavior>();
cfg.AddRequestPreProcessor<PingPreProcessor>();
cfg.AddRequestPostProcessor<PingPongPostProcessor>();
cfg.AddOpenBehavior(typeof(GenericBehavior<,>));
});
With additional methods for open generics and overloads for explicit service types.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- MediatR.Contracts (>= 2.0.1 && < 3.0.0)
- Microsoft.Bcl.AsyncInterfaces (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
-
net6.0
- MediatR.Contracts (>= 2.0.1 && < 3.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
NuGet packages (2.2K)
Showing the top 5 NuGet packages that depend on MediatR:
Package | Downloads |
---|---|
MediatR.Extensions.Microsoft.DependencyInjection
MediatR extensions for ASP.NET Core |
|
MediatR.Extensions.Autofac.DependencyInjection
An extension for Autofac-IoC to use MediatR and CQRS with ease. |
|
Elsa.Abstractions
Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. This package provides abstractions and models that are used by Elsa.Core and other related packages. You don't need to reference this package separately if you reference any other Elsa package. |
|
Elsa.Core
Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. This package contains the core of Elsa. Tip: reference the `Elsa` package instead of this one. |
|
MediatR.Extensions.FluentValidation.AspNetCore
MediatR extension to FluentValidation for .NET framework. |
GitHub repositories (214)
Showing the top 20 popular GitHub repositories that depend on MediatR:
Repository | Stars |
---|---|
jasontaylordev/CleanArchitecture
Clean Architecture Solution Template for ASP.NET Core
|
|
ardalis/CleanArchitecture
Clean Architecture Solution Template: A proven Clean Architecture Template for ASP.NET Core 9
|
|
kgrzybek/modular-monolith-with-ddd
Full Modular Monolith application with Domain-Driven Design approach.
|
|
dotnet-architecture/eShopOnWeb
Sample ASP.NET Core 8.0 reference application, now community supported: https://github.com/NimblePros/eShopOnWeb
|
|
dotnet/eShop
A reference .NET application implementing an eCommerce site
|
|
MassTransit/MassTransit
Distributed Application Framework for .NET
|
|
louthy/language-ext
C# pure functional programming framework - come and get declarative!
|
|
EduardoPires/EquinoxProject
Web Application ASP.NET 8 using Clean Architecture, DDD, CQRS, Event Sourcing and a lot of good practices
|
|
fullstackhero/dotnet-starter-kit
Production Grade Cloud-Ready .NET 9 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
|
|
jasontaylordev/NorthwindTraders
Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core.
|
|
dotnetcore/Util
Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。
|
|
simplcommerce/SimplCommerce
A simple, cross platform, modulith ecommerce system built on .NET
|
|
fullstackhero/blazor-starter-kit
Clean Architecture Template for Blazor WebAssembly Built with MudBlazor Components.
|
|
oskardudycz/EventSourcing.NetCore
Examples and Tutorials of Event Sourcing in .NET
|
|
discord-net/Discord.Net
An unofficial .Net wrapper for the Discord API (https://discord.com/)
|
|
aspnetrun/run-aspnetcore-microservices
Microservices on .NET platforms used ASP.NET Web API, Docker, RabbitMQ, MassTransit, Grpc, Yarp API Gateway, PostgreSQL, Redis, SQLite, SqlServer, Marten, Entity Framework Core, CQRS, MediatR, DDD, Vertical and Clean Architecture implementation with using latest features of .NET 8 and C# 12
|
|
kgrzybek/sample-dotnet-core-cqrs-api
Sample .NET Core REST API CQRS implementation with raw SQL and DDD using Clean Architecture.
|
|
martinothamar/Mediator
A high performance implementation of Mediator pattern in .NET using source generators.
|
|
vietnam-devs/coolstore-microservices
A full-stack .NET microservices build on Dapr and Tye
|
|
evolutionary-architecture/evolutionary-architecture-by-example
Navigate the complex landscape of .NET software architecture with our step-by-step, story-like guide. Unpack the interplay between modular monoliths, microservices, domain-driven design, and various architectural patterns. Go beyond the one-size-fits-all solutions and understand how to blend these approaches based on your unique needs.
|
Version | Downloads | Last updated |
---|---|---|
12.5.0 | 227,416 | 12 days ago |
12.4.1 | 19,192,781 | 7 months ago |
12.4.0 | 5,360,941 | 9 months ago |
12.3.0 | 6,702,492 | 6/6/2024 |
12.2.0 | 26,074,867 | 11/17/2023 |
12.1.1 | 16,619,169 | 7/10/2023 |
12.0.1 | 17,488,189 | 2/23/2023 |
11.1.0 | 14,381,347 | 11/19/2022 |
11.0.0 | 18,144,168 | 9/30/2022 |
10.0.1 | 37,667,812 | 1/10/2022 |
10.0.0 | 996,306 | 1/6/2022 |
9.0.0 | 61,208,346 | 10/8/2020 |
8.1.0 | 11,482,969 | 7/27/2020 |
8.0.2 | 2,360,715 | 6/30/2020 |
8.0.1 | 10,784,221 | 2/27/2020 |
8.0.0 | 8,942,727 | 12/30/2019 |
7.0.0 | 12,710,307 | 4/30/2019 |
6.0.0 | 6,602,722 | 12/10/2018 |
5.1.0 | 3,126,503 | 7/30/2018 |
5.0.1 | 972,635 | 6/1/2018 |
5.0.1-alpha-0002 | 42,045 | 4/5/2018 |
5.0.1-alpha-0001 | 3,605 | 4/5/2018 |
4.1.0 | 2,118,427 | 3/20/2018 |
4.0.1 | 1,078,319 | 12/4/2017 |
4.0.0 | 169,433 | 11/30/2017 |
4.0.0-alpha-0002 | 3,640 | 11/30/2017 |
4.0.0-alpha | 4,988 | 11/29/2017 |
3.0.1 | 1,430,016 | 3/7/2017 |
3.0.0 | 330,331 | 1/4/2017 |
2.1.0 | 810,045 | 7/1/2016 |
2.1.0-beta-19 | 4,334 | 5/23/2016 |
2.0.2 | 370,340 | 8/5/2015 |
2.0.1 | 5,504 | 8/5/2015 |
2.0.0 | 10,112 | 8/4/2015 |
2.0.0-beta-005 | 5,597 | 7/2/2015 |
2.0.0-beta-004 | 17,959 | 4/20/2015 |
2.0.0-beta-003 | 4,674 | 4/20/2015 |
2.0.0-beta-002 | 3,838 | 4/19/2015 |
2.0.0-beta-001 | 6,188 | 2/16/2015 |
1.0.0 | 68,104 | 12/16/2014 |
0.5.0 | 11,946 | 7/7/2014 |
0.4.0 | 4,217 | 6/16/2014 |
0.3.0 | 5,058 | 3/20/2014 |
0.2.0 | 5,190 | 3/6/2014 |
0.1.0 | 204,567 | 3/4/2014 |