/// <summary> /// Gets the Configuration Graph with the given Filename returns it /// </summary> /// <param name="context">HTTP Context</param> /// <param name="configFile">Configuration File</param> /// <returns></returns> public static IGraph LoadConfigurationGraph(HttpContext context, String configFile) { //Whenever the Configuration Graph is loaded set the Path Resolver to be the WebConfigurationPathResolver ConfigurationLoader.PathResolver = new WebConfigurationPathResolver(context.Server); //Use a caching mechanism for Config Graphs if (context.Cache[WebConfigGraphCacheKey + Path.GetFileName(configFile)] == null) { Graph g = new Graph(); FileLoader.Load(g, configFile); context.Cache.Add(WebConfigGraphCacheKey + Path.GetFileName(configFile), g, new System.Web.Caching.CacheDependency(configFile), System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, WebConfigGraphCacheDuration, 0), System.Web.Caching.CacheItemPriority.Normal, null); //Make sure to auto-detect any Object Factories and custom Parsers/Writers from the Graph ConfigurationLoader.AutoDetectObjectFactories(g); ConfigurationLoader.AutoDetectReadersAndWriters(g); return(g); } else { Object temp = context.Cache[WebConfigGraphCacheKey + Path.GetFileName(configFile)]; if (temp is IGraph) { //Q: Do we need to call the AutoDetectX() methods again here or not? //ConfigurationLoader.AutoDetectObjectFactories((IGraph)temp); return((IGraph)temp); } else { Graph g = new Graph(); FileLoader.Load(g, configFile); context.Cache.Add(WebConfigGraphCacheKey + Path.GetFileName(configFile), g, new System.Web.Caching.CacheDependency(configFile), System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, WebConfigGraphCacheDuration, 0), System.Web.Caching.CacheItemPriority.Normal, null); //Make sure to auto-detect any Object Factories and custom Parsers/Writers from the Graph ConfigurationLoader.AutoDetectObjectFactories(g); ConfigurationLoader.AutoDetectReadersAndWriters(g); return(g); } } }