/// <summary> /// 创建数据库实例。 /// </summary> /// <param name="serverType">数据服务器类型</param> /// <param name="connString">数据连接字符串</param> /// <returns></returns> public static IDbHelper Create(ServerType serverType, string connString) { //检查缓存 string key = serverType.ToString() + "|" + connString; if (_helperList.ContainsKey(key)) { return(_helperList[key].CloneNew()); } //反射实例化对象 string className = GetInstanceClassName(serverType) + "Helper"; Assembly ass = Assembly.GetExecutingAssembly(); IDbHelper helper = ass.CreateInstance(className, false, BindingFlags.Default, null, new object[] { serverType, connString }, null, null) as IDbHelper; if (helper == null) { throw new DataObjectException("未能实例化数据库 Helper 对象!"); } if (!_helperList.ContainsKey(key)) { _helperList[key] = helper; } return(helper.CloneNew()); //throw new DataObjectException("配置文件 ConnectionString 节的 ProviderName 信息不正确!没有实现关于此数据连接类型的 DbHelper 插件!"); }