I have an interface.
public interface ISomeInterface {...}
and two implementations (SomeImpl1 and SomeImpl2):
public class SomeImpl1 : ISomeInterface {...}
public class SomeImpl2 : ISomeInterface {...}
I also have two services where I inject ISomeInterface (via contructor):
public class Service1 : IService1
{
public Service1(ISomeInterface someInterface)
{
}
...
}
and
public class Service2 : IService2
{
public Service2(ISomeInterface someInterface)
{
}
...
}
I'm using Autofac as my IoC tool.
The question. How can I configure Autofac registrations so SomeImpl1 will be automatically injected into Service1, and SomeImpl2 will be automatically injected into Service2.
Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…