coreclr

How to register multiple implementations of the same interface in Asp.Net Core?

别说谁变了你拦得住时间么 提交于 2019-11-26 12:03:31
I have services that are derived from same interface public interface IService { } public class ServiceA : IService { } public class ServiceB : IService { } public class ServiceC : IService { } Typically other IOC containers like Unity allow you to register concrete implementations by some Key that distinguishes them. In Asp.Net Core how do I register these services and resolve it at runtime based on some key? I don't see any of the Add Service method takes key or name parameter that typically used to distinguish the concrete implementation. public void ConfigureServices(IServiceCollection

How to register multiple implementations of the same interface in Asp.Net Core?

怎甘沉沦 提交于 2019-11-26 01:05:37
问题 I have services that are derived from same interface public interface IService { } public class ServiceA : IService { } public class ServiceB : IService { } public class ServiceC : IService { } Typically other IOC containers like Unity allow you to register concrete implementations by some Key that distinguishes them. In Asp.Net Core how do I register these services and resolve it at runtime based on some key? I don\'t see any of the Add Service method takes key or name parameter that