aspnet / DependencyInjection

[Archived] Contains common DI abstractions that ASP.NET Core and Entity Framework Core use. Project moved to https://github.com/aspnet/Extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resolve a service with multiple implementations based on consumer metadata

broomandan opened this issue · comments

Hi,
Is there a simple way (like Simple Injector) to register multiple implementations for an interface and inject an specific implementation into a consumer?

For instance:
I have two components (A and B) that are consuming two different implementations (ServiceA, ServiceB) of an interface (IService) factories. I want to be able to instruct the DI resolver, when component A is asking for IService inject implementation ServiceA and when component B is asking for IService, inject ServiceB implementation.
Simple injector is solving this by providing consumers metadata at resolution time.

image

Is this feature on the road-map? I would be more than happy to contribute.

Best,
Robert Broomandan

@broomandan we don't use the issue tracker on this repo. We're going to merge this repo into https://github.com/aspnet/Extensions in the next few days and deprecate this repo. Can you re-open your issue there?

Thanks,
Nate