抽象工厂不同接口反射

public static T xueshengbiaoDAO<T>() where T:class {

 

 

string DllName = ConfigurationManager.AppSettings["DllName"];
Assembly assemblys = Assembly.Load(DllName);//载入程序集
Type[] Types = assemblys.GetTypes();
Type jiekou = null;
for (int a = 0; a < Types.Length; a++)
{


if (typeof(T).IsAssignableFrom(Types[a]))
{

jiekou = Types[a];
break;


}


}

return (T)Activator.CreateInstance(jiekou);

 

 



}

posted @ 2018-03-17 22:45  西瓜冰镇老板  阅读(130)  评论(0编辑  收藏  举报