【发布时间】:2010-06-04 00:57:21
【问题描述】:
我有一个泛型类,它使用 TBase 作为类型参数。使用 MEF,我想要一个应该导入的通用类型列表。我试着用这个:
1)
[ImportMany(typeof(TBase))]
public List<TBase> ObjectList { get; set; }
2)
Type IValueType = typeof(TBase)
[ImportMany(IValueType)]
public List<TBase> ObjectList{ get; set; }
3)
[ImportMany(TBase)]
public List<TBase> ObjectList{ get; set; }
首秀
{'TBase': an attribute argument cannot use type parameters}
第二场演出
{An object reference is required for the non-static field, method, or property}
第三场演出
{'TBase' is a 'type parameter' but is used like a 'variable'}
我在这里做错了什么?我该如何解决?
【问题讨论】: