111,120
社区成员
发帖
与我相关
我的任务
分享private readonly IDBOperator<jm.Model.Customer> icustomer = OperatorFactory.CreateDBOperator<jm.Model.Customer>("jm.BLL.Customer");private readonly IDBOperator<jm.Model.Customer> icustomer = OperatorFactory.CreateDBOperator<jm.BLL.Customer, jm.Model.Customer>();
public interface IDBOperator<T>
{
long Add(T model);
}
public partial class CustomerOP : IDBOperator<Customer>
{
public long Add(Customer model)
{
return 0;
}
}
public class Customer
{
}
public class Factory
{
public static IDBOperator<T> Create<T>(string classname)
{
Type type = Type.GetType(classname);
return (IDBOperator<T>)Activator.CreateInstance(type);
}
}
public static jm.Interface.IDBOperator<T> CreateDBOperator<T>()
{
//...
return (jm.Interface.IDBOperator<T>)objType;
}