比如 “NewsCenter” 反射或其它办法 转换成 NewsCenter这个类类型?
System.Reflection.Assembly.GetExecutingAssembly().CreateInstance("..NewsCenter", false);
只是创建了类型实例,我不希望创建实例
主要是我有个泛型方法,泛型参数是类型,我不想每次有新增的类型都去修改源代码
private DataTable getNewsDataTable4Tree<T, TView>(INewsCategoryFacade<T, TView> NewsCategoryFacade, string myCategoryIDs)
//where T:NewsCategory
//where TView:NewsCategoryView
{
if (myCategoryIDs == null)
return DataTableHelper.ToDataTable<T>(NewsCategoryFacade.getList4Tree());
else
return DataTableHelper.ToDataTable<T>(NewsCategoryFacade.getList4Tree(myCategoryIDs));
}
private void BindViewTree(TreeView tree, string configKey, string myCategoryIDs)
{
switch (configKey)
{
case "NewsCenter":
InitViewTree(tree.Nodes, "0", getNewsDataTable4Tree<NewsCenterCategory, NewsCenterCategoryView>(NewsCenterCategoryFacade, myCategoryIDs));
break;
case ""
}
}