Given the following code, how do I resolve the right SomeInstance in autofac?
public class BaseClass {}
public class SubClass1 : BaseClass {}
public class SubClass2 : BaseClass {}
public interface IGenericInterface<T> where T : BaseClass {}
public class SomeInstance1<T> : IGenericInterface<T> where T : SubClass1
public class SomeInstance2<T> : IGenericInterface<T> where T : SubClass2
I want to choose SomeInstance1 or 2 based on the type of of the generic on the sub classes.
So for example I have a collection of sub classes (SubClass1, 2....) and while iterating over them I want to choose the right SomeInstance class.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…