public static FileSystemConfiguration GetConfig() { FileSystemConfiguration editorConfig = null; if ( (HttpRuntime.Cache["mojoFileSystemConfig"] != null) && (HttpRuntime.Cache["mojoFileSystemConfig"] is FileSystemConfiguration) ) { return (FileSystemConfiguration)HttpRuntime.Cache["mojoFileSystemConfig"]; } else { String configFileName = WebConfigSettings.mojoFileSystemConfigFileName; if (!configFileName.StartsWith("~/")) { configFileName = "~/" + configFileName; } String pathToConfigFile = HttpContext.Current.Server.MapPath(configFileName); XmlDocument configXml = new XmlDocument(); configXml.Load(pathToConfigFile); editorConfig = new FileSystemConfiguration(configXml.DocumentElement); AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency(); aggregateCacheDependency.Add(new CacheDependency(pathToConfigFile)); System.Web.HttpRuntime.Cache.Insert( "mojoFileSystemConfig", editorConfig, aggregateCacheDependency, DateTime.Now.AddYears(1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); return (FileSystemConfiguration)HttpRuntime.Cache["mojoFileSystemConfig"]; } }
public static FileSystemConfiguration GetConfig() { FileSystemConfiguration editorConfig = null; if ( (HttpRuntime.Cache["mojoFileSystemConfig"] != null) && (HttpRuntime.Cache["mojoFileSystemConfig"] is FileSystemConfiguration) ) { return((FileSystemConfiguration)HttpRuntime.Cache["mojoFileSystemConfig"]); } else { String configFileName = WebConfigSettings.mojoFileSystemConfigFileName; if (!configFileName.StartsWith("~/")) { configFileName = "~/" + configFileName; } String pathToConfigFile = HttpContext.Current.Server.MapPath(configFileName); XmlDocument configXml = new XmlDocument(); configXml.Load(pathToConfigFile); editorConfig = new FileSystemConfiguration(configXml.DocumentElement); AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency(); aggregateCacheDependency.Add(new CacheDependency(pathToConfigFile)); System.Web.HttpRuntime.Cache.Insert( "mojoFileSystemConfig", editorConfig, aggregateCacheDependency, DateTime.Now.AddYears(1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); return((FileSystemConfiguration)HttpRuntime.Cache["mojoFileSystemConfig"]); } }
private static void Initialize() { FileSystemConfiguration config = FileSystemConfiguration.GetConfig(); if ( (config.DefaultProvider == null) || (config.Providers == null) || (config.Providers.Count < 1) ) { throw new ProviderException("You must specify a valid default provider."); } providerCollection = new FileSystemProviderCollection(); ProvidersHelper.InstantiateProviders( config.Providers, providerCollection, typeof(FileSystemProvider)); providerCollection.SetReadOnly(); defaultProvider = providerCollection[config.DefaultProvider]; }