/// <summary> /// /// </summary> /// <param name="sectionName"></param> /// <exception cref="Exception"></exception> /// <returns></returns> public static bool Intialize(string sectionName) { lock (syncRoot) { var section = ConfigurationManager.GetSection(sectionName); if (section is IConfigger) { var instance = section as IConfigger; instance.Install(); _configgerSet.Add(instance); _configger = instance; return(true); } return(false); } }
/// <summary> /// /// </summary> /// <param name="sectionName"></param> /// <exception cref="ArgumentException"></exception> /// <exception cref="Exception"></exception> /// <returns></returns> public static void Intialize(string sectionName) { lock (syncRoot) { var section = ConfigurationManager.GetSection(sectionName); if (section is IConfigger) { var instance = section as IConfigger; instance.Install(); _configgerSet.Add(instance); _configger = instance; } else { throw new ArgumentException("Not found section node.", "sectionName"); } } }
/// <summary> /// /// </summary> /// <returns></returns> /// <exception cref="Exception"></exception> public static IConfigger GetConfigger(Type type) { lock (syncRoot) { foreach (IConfigger configger in _configgerSet) { if (configger.GetType() == type) { _configger = configger; return(configger); } } var instance = type.CreateInstance <IConfigger>(); instance.Install(); _configgerSet.Add(instance); _configger = instance; return(instance); } }