/// <summary> /// Gets the config. /// </summary> /// <returns></returns> public static T GetConfig() { //Optimization (no need to enter lock in most cases) if (_config != null) { return(_config); } //RaceCondition removed with this lock. lock (Mutex) { if (_config == null) { _config = ConfigurationReader.GetConfig <T>(); if (_config == null) { throw new ConfigurationErrorsException( string.Format("Configuration section \"{0}\" not found", typeof(T).Name)); } // Do after initialization. _config.Initialize(); } } return(_config); }
/// <summary> /// Gets the config. /// </summary> /// <returns></returns> public static T GetConfig() { if (_config == null) { _config = ConfigurationReader.GetConfig <T>(); if (_config == null) { throw new ConfigurationErrorsException( string.Format("Configuration section \"{0}\" not found", typeof(T).Name)); } } return(_config); }