//********************************************************************* // // GetSiteSettings Static Method // // The Configuration.GetSiteSettings Method returns a typed // dataset of the all of the site configuration settings from the // XML configuration file. This method is used in Global.asax to // push the settings into the current HttpContext, so that all of the // pages, content modules and classes throughout the rest of the request // may access them. // // The SiteConfiguration object is cached using the ASP.NET Cache API, // with a file-change dependency on the XML configuration file. Normallly, // this method just returns a copy of the object in the cache. When the // configuration is updated and changes are saved to the the XML file, // the SiteConfiguration object is evicted from the cache. The next time // this method runs, it will read from the XML file again and insert a // fresh copy of the SiteConfiguration into the cache. // //********************************************************************* public static SiteConfiguration GetSiteSettings() { SiteConfiguration siteSettings = (SiteConfiguration)HttpContext.Current.Cache["SiteSettings"]; // If the SiteConfiguration isn't cached, load it from the XML file and add it into the cache. if (siteSettings == null) { // Create the dataset siteSettings = new SiteConfiguration(); // Retrieve the location of the XML configuration file string configFile = HttpContext.Current.Server.MapPath(ConfigurationSettings.AppSettings["configFile"]); // Set the AutoIncrement property to true for easier adding of rows siteSettings.Tab.TabIdColumn.AutoIncrement = true; siteSettings.Module.ModuleIdColumn.AutoIncrement = true; siteSettings.ModuleDefinition.ModuleDefIdColumn.AutoIncrement = true; // Load the XML data into the DataSet siteSettings.ReadXml(configFile); // Store the dataset in the cache HttpContext.Current.Cache.Insert("SiteSettings", siteSettings, new CacheDependency(configFile)); } return(siteSettings); }