我有一个泛型基类,其中泛型类型是类和其他相关的继承类:
public class BaseClass<T> where T : class
{
virtual void DoWork(){..}
virtual void DoAnotherWork(){..}
}
public class SomeInherit<Person> : BaseClass<Person>
{
//...
}
public class OtherInherit<Car> : BaseClass<Car>
{
// override something..
}
然后,我有一个 BaseClassManager,它应该能够加载一些同事通过反射继承的 BaseClass:
public class BaseClassManager
{
public BaseClass<TItem> LoadBaseClass<T>() where T : BaseClass<???>
{
// how can create an instance of T?
// TItem : class
// T : BaseClass
// -------------> in reality, it should be: T<TItem> (just as BaseClass<Person>)
}
}
有没有办法做到这一点..?