【发布时间】:2008-10-24 11:59:38
【问题描述】:
我有一个抽象泛型类BLL<T> where T : BusinessObject。我需要打开一个包含一组具体 BLL 类的程序集,并在 Dictionary 中返回元组(businessObjectType、concreteBLLType)。到目前为止,我可以做部分方法,但是我在发现 T 时遇到了问题。
protected override Dictionary<Type, Type> DefineBLLs()
{
string bllsAssembly = ConfigurationManager.AppSettings["BLLsAssembly"];
Type[] types = LoadAssembly(bllsAssembly);
Dictionary<Type, Type> bllsTypes = new Dictionary<Type, Type>();
foreach (Type type in types)
{
if (type.IsSubclassOf(typeof(BLL<>)))
/* how to know T in the situation below? */
bllsTypes.Add(??businessObjectType (T)??, type);
}
return bllsTypes;
}
【问题讨论】:
-
那么,这里的 T 与什么有关?目前尚不清楚(至少对我而言)代码代表什么。
-
我认为 Jon 可能为你清除了代码。
标签: c# generics reflection