-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Using MS.Extensions.DI directly, removing all unneeded code, pulling in the MediatR package directly #802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@jbogard Just wanted to ask if you are aware of the consequences for simple injector (and maybe other containers). For general discussion regarding conforming containers see from former discussions such as dotnet/aspnetcore#30115, dotnet/aspnetcore#29194, dotnet/aspnetcore#28957, dotnet/aspnetcore#14585, dotnet/aspnetcore#8886 and aspnet/DependencyInjection#334. So this change would break support for SimpleInjector. Realistically, there would be no way back (rather than forking). |
|
How would this break exactly? Doesn't the This doesn't force people to use the |
Ah, I see. Thanks for the clarification. I originally thought it requires using the frameworks DI Container (IServiceCollection). Container.RegisterInstance(typeof(IMediator), new Mediator(Container.GetInstance));
It does currently, yes. May be removed in the future though. But then we can still write a simple adapter: Container.RegisterInstance(typeof(IMediator), new Mediator(new ServiceProviderAdapter { Container = container }));
public class ServiceProviderAdapter : IServiceProvider
{
public Container Container {get;set;}
public object GetService(Type type) => this.Container.GetInstanceOrNull(type);
}So everything seems to be good :-) |
|
Yep, you should be able to write a simple adapter. MediatR used to use CommonServiceLocator years and years ago so this is a bit of return to form. I don't plan on altering anything with MediaR internals to force using its registration. In fact, I'm looking at adding factory objects to make it a bit more explicit about instantiating things like behaviors. |
Brrrrrrrr