110,535
社区成员
发帖
与我相关
我的任务
分享
namespace accessdal
{
public class SqlHelperX<T>:ISqlHelperX<T>
where T:new ()
{…………}
}
namespace Dal
{
public static class Factory
{
public static IXhpSqlParam CreateXhpSqlParam()//非泛型,这里没有疑问。
{
return (IXhpSqlParam)Assembly.Load(path).CreateInstance(path + ".XhpSqlParam");
}
public static ISqlHelperX<T> CreateSqlHelperX<T>() //泛型,这里创建出来为null
where T : new()
{
return (ISqlHelperX<T>)Assembly.Load(path).CreateInstance(path + ".SqlHelperX<" + typeof(T).FullName + ">")
}
}
public class SqlHelperX<T>
where T:new()
{
public static bool Insert(T t, string keyName)
{
return Dal.Factory.CreateSqlHelperX<T>().Insert(t, keyName) > 0;
}
}
public static ISqlHelperX<T> CreateSqlHelperX<T>()
where T : new()
{
Assembly a = Assembly.Load(path);
Type t = a.GetType((path +".SqlHelperX`1");
Type[] typeArgs = { typeof(T) };
Type constructed = t.MakeGenericType(typeArgs);
return (ISqlHelperX<T>)System.Activator.CreateInstance(constructed);
}