/// <summary> /// Loads the path configuration class. /// </summary> /// <param name="classInfo">The class information.</param> /// <returns></returns> /// <exception cref="System.ArgumentException">BestBetPathConfiguration must implement type IBestBetPathConfiguration</exception> private IBestBetPathConfiguration LoadPathConfigurationClass(string classInfo) { IBestBetPathConfiguration rtnConfig = null; //Will throw exception if class cannot be found or bogus Type t = Type.GetType(classInfo, true, true); if (!typeof(IBestBetPathConfiguration).IsAssignableFrom(t)) { throw new ArgumentException("BestBetPathConfiguration must implement type " + typeof(IBestBetPathConfiguration).ToString()); } rtnConfig = (IBestBetPathConfiguration)Activator.CreateInstance(t); return(rtnConfig); }
/// <summary> /// Initializes this instance. /// </summary> private void Initialize() { //Get the configuration section BestBetsSection config = (BestBetsSection)ConfigurationManager.GetSection("nci/search/bestbets"); if (config == null) { throw new ConfigurationErrorsException("BestBetsSection (nci/search/bestbets) is missing from configuration"); } //Load the path config if (String.IsNullOrWhiteSpace(config.PathConfigurationClass)) { throw new ConfigurationErrorsException("pathConfigurationClass is required for BestBetsSection (nci/search/bestbets)"); } //We should be inside a block of code that has a lock, so no need to lock class. IBestBetPathConfiguration pathConfig = LoadPathConfigurationClass(config.PathConfigurationClass); //Get configuration information _luceneIndexPath = pathConfig.LuceneIndexPath; _bestBetsPath = pathConfig.BestBetsFilePath; if (!IO.Directory.Exists(_luceneIndexPath)) { IO.Directory.CreateDirectory(_luceneIndexPath); } //We are using an MMapDirectory as the default option (FSSimpleDirectory) does not handle //multi-threading well. _luceneIndex = MMapDirectory.Open(_luceneIndexPath); //If there is no index at that location, then build the index. Otherwise, we will //let the scheduler build it. if (!IndexReader.IndexExists(_luceneIndex)) { BuildIndex(); } }