/// <summary> /// 移除配置对象 /// </summary> /// <param name="cfg"></param> public void Remove(DbProviderFactoryConfiguration cfg) { if (cfg != null) { Remove(cfg.Name); } }
/// <summary> /// 添加配置对象 /// </summary> /// <param name="cfg"></param> public void Add(DbProviderFactoryConfiguration cfg) { if (cfg == null) { throw new ArgumentNullException(" cfg is null "); } m_Factories[cfg.Name] = cfg; }
/// <summary> /// 填充一个配置对象 /// </summary> /// <param name="conf"></param> /// <returns></returns> public virtual DbProviderFactoryConfiguration LoadConf(XmlNode conf) { if (conf == null) { throw new ArgumentNullException("conf is Nullable"); } XmlNode xName = conf.SelectSingleNode("Name"); XmlNode xDbAdapter = conf.SelectSingleNode("DbAdapter"); String Name = xName == null ? "" : xName.InnerText; String DbAdapter = xDbAdapter == null ? "" : xDbAdapter.InnerText; if (!String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(DbAdapter)) { DbProviderFactoryConfiguration cfg = new DbProviderFactoryConfiguration(Name, DbAdapter); return(cfg); } return(null); }
/// <summary> /// 加载配置列表 /// </summary> /// <param name="conf"></param> /// <returns></returns> public virtual DbProviderFactoriesConfiguration Load(XmlElement conf) { if (conf == null) { throw new ArgumentNullException("conf is Nullable"); } DbProviderFactoriesConfiguration cfgs = new DbProviderFactoriesConfiguration(); XmlNodeList list = conf.SelectNodes("DbProvider"); if (list != null && list.Count > 0) { foreach (XmlNode n in list) { DbProviderFactoryConfiguration cfg = LoadConf(n); if (cfg != null) { cfgs.Add(cfg); } } } return(cfgs); }