예제 #1
0
 private static void Initialize()
 {
     SearchProvider = new AzureIndexProvider();
 }
예제 #2
0
        /// <summary>
        /// Gets a search configuration by scanning available index providers in order of preference 
        /// and taking the first available one found.
        /// </summary>
        /// <remarks>
        /// This is supplied to the search system as a func and invoked when needed.
        /// </remarks>
        /// <returns>SearchContextConfiguration.</returns>
        private TdSearchContextConfiguration GetSearchConfiguration()
        {
            //TODO: when we move to a plug-in model, this should be refactored to use an applicaiton setting.
            //  Application settings will determine the order of preference for providers
            //  Func will cheack each in order, returing the first match found.
            //  By default, the system will assume that any custom plug-ins installed are 
            //  preferred (in alphabetical order if more than one), then Azure, and finally 
            //  Lucene as a last resort provider.
            //
            //  It would be nice if there were a way to detect if a provider was configured 
            //  and ready for use without fully instantiating the provider, but this may be
            //  cumbersome since interfaces can't specify static members, and any other 
            //  mechanism seems like it would be somewhat convoluted for would-be plug-in 
            //  autors to implement.

            var azProvider = new AzureIndexProvider();
            var config = azProvider.IsConfigured ?
                new TdSearchContextConfiguration(azProvider, new AzureSearchLocatorProvider()) :
                new TdSearchContextConfiguration(new LuceneIndexProvider(), new LuceneSearchLocatorProvider());
            return config;
        }