/// <summary> /// Returns the global (singleton) <c>SitesConfig</c> object. /// </summary> /// <returns></returns> public static SitesConfig GetInstance() { if (instance == null) { // ensure only one thread is able to instantiate an instance at a time. lock (syncRoot) { if (instance == null) { // get the path to the sites.config file from web.config String sitesConfigPath = ConfigurationSettings.AppSettings["sitesConfigPath"]; // TODO: make sure we got a path -- throw exception? try { LogManager.GetCurrentClassLogger().Info( infoMessage => infoMessage("SitesConfig - starting load.")); // make the XmlConfiguration object for the sites.config file instance = new SitesConfig(); //instance.Load(Info.BasePath + sitesConfigPath); instance.Load(AppInfo.BasePath + sitesConfigPath); LogManager.GetCurrentClassLogger().Info( infoMessage => infoMessage("SitesConfig - load completed.")); } catch (Exception e) { LogManager.GetCurrentClassLogger().Error( errorMessage => errorMessage("SitesConfig.GetInstance: "), e); throw; } } } } return instance; }
/// <summary> /// Resets the SitesConfig singleton, forcing it to be reinitialized when /// next referenced. /// </summary> public void Reset() { instance = null; LogManager.GetCurrentClassLogger().Info( infoMessage => infoMessage("SitesConfig reset.")); }