目前,我需要像这样在运行时构建类型定义,并将其传递给我的IOC进行解析。简化的代码如下:
Type t = Type.GetType(
"System.Collections.Generic.List`1[[ConsoleApplication2.Program+Person");
我知道泛型类型参数只能在运行时确定。
是否有方法可以实现类似以下的操作(伪代码):
Type t = Type.GetTypeWithGenericTypeArguments(
typeof(List)
, passInType.GetType());
或者我只是坚持我的hack,passInType.GetType()
转换成字符串,构建泛型类型字符串.. 感觉很不好