public static mojoProfileConfiguration GetConfig() { mojoProfileConfiguration profileConfig = null; string cacheKey = GetCacheKey(); if ( (System.Web.HttpRuntime.Cache[cacheKey] != null) && (System.Web.HttpRuntime.Cache[cacheKey] is mojoProfileConfiguration) ) { return((mojoProfileConfiguration)System.Web.HttpRuntime.Cache[cacheKey]); } else { string configFileName = GetConfigFileName(); if (configFileName.Length == 0) { return(profileConfig); } if (!configFileName.StartsWith("~/")) { configFileName = "~/" + configFileName; } string pathToConfigFile = HttpContext.Current.Server.MapPath(configFileName); XmlDocument configXml = new XmlDocument(); configXml.Load(pathToConfigFile); profileConfig = new mojoProfileConfiguration(configXml.DocumentElement); AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency(); aggregateCacheDependency.Add(new CacheDependency(pathToConfigFile)); // more dependencies can be added if needed System.Web.HttpRuntime.Cache.Insert( cacheKey, profileConfig, aggregateCacheDependency, DateTime.Now.AddYears(1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); return((mojoProfileConfiguration)System.Web.HttpRuntime.Cache[cacheKey]); } }
public static mojoProfileConfiguration GetConfig() { mojoProfileConfiguration profileConfig = null; string cacheKey = GetCacheKey(); if ( (System.Web.HttpRuntime.Cache[cacheKey] != null) && (System.Web.HttpRuntime.Cache[cacheKey] is mojoProfileConfiguration) ) { return (mojoProfileConfiguration)System.Web.HttpRuntime.Cache[cacheKey]; } else { string configFileName = GetConfigFileName(); if (configFileName.Length == 0) { return profileConfig; } if (!configFileName.StartsWith("~/")) { configFileName = "~/" + configFileName; } string pathToConfigFile = HttpContext.Current.Server.MapPath(configFileName); XmlDocument configXml = new XmlDocument(); configXml.Load(pathToConfigFile); profileConfig = new mojoProfileConfiguration(configXml.DocumentElement); AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency(); aggregateCacheDependency.Add(new CacheDependency(pathToConfigFile)); // more dependencies can be added if needed System.Web.HttpRuntime.Cache.Insert( cacheKey, profileConfig, aggregateCacheDependency, DateTime.Now.AddYears(1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); return (mojoProfileConfiguration)System.Web.HttpRuntime.Cache[cacheKey]; } }