Leveraging Microsoft.Extensions.DependencyInjection.Abstractions directly
The Mediator class now references IServiceProvider directly, instead of the previous custom delegate:
- public Mediator(ServiceFactory serviceFactory)
- => _serviceFactory = serviceFactory;
+ public Mediator(IServiceProvider serviceProvider)
+ : this(serviceProvider, new ForeachAwaitPublisher()) { }
+ public Mediator(IServiceProvider serviceProvider, INotificationPublisher publisher)
+ {
+ _serviceProvider = serviceProvider;
+ _publisher = publisher;
+ }
The functionality of MediatR.Extensions.DependencyInjection.Abstractions is now folded in directly to MediatR itself, so you can remove the reference to the extensions package and call the MediatR package directly:
services.AddMediatR(/* registration */);
For codebases not using the extension package, you may either implement IServiceProvider directly, or for many containers, they already directly support IServiceProvider directly.
Changes in Mediatr v12 resolving ServiceFactory have impacted compatibility with this library v9.2.
I had a look, but admit I got lost in implementing the changes required to this library to attempt a PR.
From their repo: https://github.com/jbogard/MediatR/wiki/Migration-Guide-11.x-to-12.0
Leveraging Microsoft.Extensions.DependencyInjection.Abstractions directly The Mediator class now references IServiceProvider directly, instead of the previous custom delegate:
The ServiceFactory delegate was removed:
The functionality of MediatR.Extensions.DependencyInjection.Abstractions is now folded in directly to MediatR itself, so you can remove the reference to the extensions package and call the MediatR package directly:
For codebases not using the extension package, you may either implement IServiceProvider directly, or for many containers, they already directly support IServiceProvider directly.