/// <summary> /// 反射创建子类的实例 /// </summary> /// <returns></returns> /// <exception cref="FileNotFoundException"></exception> public static RepositoryFactory CreateRepositoryFactory() { string[] provider = AFConfigurationManager.PLGroup.provider.Split(','); if (string.IsNullOrEmpty(provider[0]) || string.IsNullOrEmpty(provider[1])) { throw new UnhandledException("配置文件Biz.config 内PLGroup Provider属性 配置有误"); } var dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, BINPATH, provider[1].Trim() + ".dll"); _repositoryFactory = (RepositoryFactory)Assembly.LoadFrom(dllPath).CreateInstance(provider[0]); return _repositoryFactory; }
/// <summary> /// 配置所有的资源 /// </summary> public static void Config() { Console.WriteLine("正在读取biz.config"); //读取平台的配置文件 TelChina.AF.Sys.Configuration.AFConfigurationManager.Setup(); //获取仓储工厂的实例 _repositoryFactory = RepositoryFactory.CreateRepositoryFactory(); Console.WriteLine("已经通过反射完成仓储工厂对象的创建"); //配置仓储工厂 _repositoryFactory.Config(); Console.WriteLine("PL相关所有配置已经完成"); #region Test Add && Remove //_repositoryFactory.AddSettingElement(new System.Configuration.SettingElement { AppName = "Demo", FileName = "hibernate1.cfg.xml" }); #endregion }
/// <summary> /// 关闭所有的资源 /// </summary> protected static void Close() { _repositoryFactory.Close(); _repositoryFactory = null; }
/// <summary> /// 应用程序关闭,清空资源 /// </summary> public virtual void Close() { _repositoryFactory = null; }