我处在以下功能中:
CreateSomething<TI>(TI inputInterface)
{
Type unknownType = SettingsSystem.GetTypeBasedOnInterface(inputInterface);
object otherInformation = SomeClass.GetInformation();
return base.CreateSomething<TI, T>(inputInterface, otherInformation);
}
,其中
base.CreateSomething
returnObject CreateSomething<TI, T>(TI interface, object otherInformation = null)
where TI : class
where T : class
{
return externalDll.DoStuff<T>(interface);
}
我需要的是一种传递类型为unknownType的类的方法,如下所示:
return base.CreateSomething<TI, unknownType>(inputInterface, otherInformation);
而不是像这样的东西
if(version == v1)
return base.CreateSomething<TI, MyClassV1>(inputInterface, otherInformation);
if(version == v2)
return base.CreateSomething<TI, MyClassV2>(inputInterface, otherInformation);