aspnet / DependencyInjection

[Archived] Contains common DI abstractions that ASP.NET Core and Entity Framework Core use. Project moved to https://github.com/aspnet/Extensions
Apache License 2.0
873 stars 318 forks source link

Resolve a service with multiple implementations based on consumer metadata #660

Closed broomandan closed 5 years ago

broomandan commented 5 years ago

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

natemcmaster commented 5 years ago

@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