抽象工厂类

///


/// 通过抽象的方式创建数据操作类的实例
///

public class AbstractFactory
{
private readonly static string NameSpace = ConfigurationManager.AppSettings["NameSpace"];
private readonly static string AssemblyPath = ConfigurationManager.AppSettings["AssemblyPath"];
private static IDAL.IUserInfoDAL CreateUserInfoDAL()
{
string fullClassName = NameSpace + ".UserInfoDAL";
return CreateInstance(fullClassName, AssemblyPath) as IDAL.IUserInfoDAL;
}

    private static object CreateInstance(string fullClassName, string AssemblyPath)
    {
        var ass= Assembly.Load(AssemblyPath);
        return ass.CreateInstance(fullClassName);
    }
}

posted on 2015-03-24 17:33  木屐  阅读(112)  评论(0编辑  收藏  举报

导航