public static LuceneSettingsConfiguration GetConfig() { LuceneSettingsConfiguration config = null; if ( (HttpRuntime.Cache["LuceneSettingsConfiguration"] != null) && (HttpRuntime.Cache["LuceneSettingsConfiguration"] is LuceneSettingsConfiguration) ) { return((LuceneSettingsConfiguration)HttpRuntime.Cache["LuceneSettingsConfiguration"]); } else { string configFileName = "LuceneSettings.config"; if (ConfigurationManager.AppSettings["LuceneSettingsConfigFileName"] != null) { configFileName = ConfigurationManager.AppSettings["LuceneSettingsConfigFileName"]; } if (!configFileName.StartsWith("~/")) { configFileName = "~/" + configFileName; } string pathToConfigFile = System.Web.Hosting.HostingEnvironment.MapPath(configFileName); XmlDocument configXml = new XmlDocument(); configXml.Load(pathToConfigFile); config = new LuceneSettingsConfiguration(configXml.DocumentElement); AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency(); aggregateCacheDependency.Add(new CacheDependency(pathToConfigFile)); System.Web.HttpRuntime.Cache.Insert( "LuceneSettingsConfiguration", config, aggregateCacheDependency, DateTime.Now.AddYears(1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); return((LuceneSettingsConfiguration)HttpRuntime.Cache["LuceneSettingsConfiguration"]); } }
private static void Initialize() { //try //{ LuceneSettingsConfiguration config = LuceneSettingsConfiguration.GetConfig(); if ( (config.DefaultProvider == null) || (config.Providers == null) || (config.Providers.Count < 1) ) { throw new ProviderException("You must specify a valid default provider."); } providerCollection = new LuceneSettingsProviderCollection(); ProvidersHelper.InstantiateProviders( config.Providers, providerCollection, typeof(LuceneSettingsProvider)); providerCollection.SetReadOnly(); defaultProvider = providerCollection[config.DefaultProvider]; //} //catch (Exception ex) //{ // initializationException = ex; // isInitialized = true; // throw ex; //} isInitialized = true; }
public static LuceneSettingsConfiguration GetConfig() { LuceneSettingsConfiguration config = null; if ( (HttpRuntime.Cache["LuceneSettingsConfiguration"] != null) && (HttpRuntime.Cache["LuceneSettingsConfiguration"] is LuceneSettingsConfiguration) ) { return (LuceneSettingsConfiguration)HttpRuntime.Cache["LuceneSettingsConfiguration"]; } else { string configFileName = "LuceneSettings.config"; if (ConfigurationManager.AppSettings["LuceneSettingsConfigFileName"] != null) { configFileName = ConfigurationManager.AppSettings["LuceneSettingsConfigFileName"]; } if (!configFileName.StartsWith("~/")) { configFileName = "~/" + configFileName; } string pathToConfigFile = System.Web.Hosting.HostingEnvironment.MapPath(configFileName); XmlDocument configXml = new XmlDocument(); configXml.Load(pathToConfigFile); config = new LuceneSettingsConfiguration(configXml.DocumentElement); AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency(); aggregateCacheDependency.Add(new CacheDependency(pathToConfigFile)); System.Web.HttpRuntime.Cache.Insert( "LuceneSettingsConfiguration", config, aggregateCacheDependency, DateTime.Now.AddYears(1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); return (LuceneSettingsConfiguration)HttpRuntime.Cache["LuceneSettingsConfiguration"]; } }