MediatR.NotificationHandling.Extensions 1.0.0

.NET Standard 2.0
dotnet add package MediatR.NotificationHandling.Extensions --version 1.0.0
NuGet\Install-Package MediatR.NotificationHandling.Extensions -Version 1.0.0
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="MediatR.NotificationHandling.Extensions" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MediatR.NotificationHandling.Extensions --version 1.0.0
#r "nuget: MediatR.NotificationHandling.Extensions, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MediatR.NotificationHandling.Extensions as a Cake Addin
#addin nuget:?package=MediatR.NotificationHandling.Extensions&version=1.0.0

// Install MediatR.NotificationHandling.Extensions as a Cake Tool
#tool nuget:?package=MediatR.NotificationHandling.Extensions&version=1.0.0

MediatR.NotificationHandling.Extensions.Microsoft.DependencyInjection

Separate dependency scope notification handling extension for MediateR using with Microsoft.Extensions.DependencyInjection. By default MediatR handles every notification in just on IServiceScope, The one IMediatR resolved with.

By using this extension every notification will be handled in separate IServiceScope thus there will be no resource or thread conflicts and every dependencies injected in the hierarchy of INotificationHandler'1 will be disposed after Handle method called; whether successful or not.

Extensions tested with modified MediatR and MediatR.Extensions.Microsoft.DependencyInjection tests to ensure compatibility and performability.

You can use extension in two ways. in every cases there are three pre conditions: 1- IMediatR must be registered with scoped lifestyle.

services.AddMediatR(cfg => cfg.AsScoped(), typeof(Startup));

2- Microsoft runtime implemetation of IServiceProvider must be IServiceScope too. (This condition depends on microsoft .net team) 3- Extension methods must be called after all notification handlers registered.

Configuring MediatR immediately after AddMediatR registered handlers:

services
	.AddMediatR(cfg => cfg.AsScoped(), typeof(Startup))
	.IsolateNotificationHandlingScopes();

Configuring MediatR after AddMediatR and some relevant registration like other handlers:

services.AddMediatR(cfg => cfg.AsScoped(), typeof(Startup));

...

services.IsolateNotificationHandlingScopes();
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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
1.0.0 4,928 6/9/2021