/// <summary>
        /// Initializes the provider and ensures that all configuration can be read
        /// </summary>
        /// <param name="builderContext"></param>
        public override void Initialise(IBuilderContext builderContext)
        {
            Mandate.ParameterNotNull(builderContext, "builderContext");

            var configMain = builderContext.ConfigurationResolver.GetConfigSection(HiveConfigSection.ConfigXmlKey) as HiveConfigSection;

            if (configMain == null)
                throw new ConfigurationErrorsException(
                    string.Format("Configuration section '{0}' not found when building packaging provider '{1}'",
                                  HiveConfigSection.ConfigXmlKey, ProviderKey));

            var config2Rw = RegistryConfigElement ?? configMain.Providers.ReadWriters[ProviderKey] ?? configMain.Providers.Readers[ProviderKey];

            if (config2Rw == null)
                throw new ConfigurationErrorsException(
                    string.Format("No configuration found for persistence provider '{0}'", ProviderKey));

            //get the Hive provider config section
            _localConfig = DeepConfigManager.Default.GetFirstPluginSection<ProviderConfigurationSection>(config2Rw.ConfigSectionKey);

            if (!ValidateProviderConfigSection<ExamineDemandBuilder>(_localConfig, config2Rw))
            {
                CanBuild = false;
                return;
            }

            var configMgr = DeepConfigManager.Default;

            //get the internal indexer provider
            _internalIndexer = configMgr.GetFirstPluginSetting<ExamineSettings, ProviderSettings>("examine/examine.settings",
                                                                                             x => x.IndexProviders.SingleOrDefault(indexer => indexer.Name == _localConfig.InternalIndexer));
            if (_internalIndexer == null)
            {
                LogHelper.Warn<ExamineDemandBuilder>("Could not load UmbracoInternalIndexer, the configuration section could not be read.");
                CanBuild = false;
                return;
            }
                
            //get the internal searcher provider
            _internalSearcher = configMgr.GetFirstPluginSetting<ExamineSettings, ProviderSettings>("examine/examine.settings",
                                                                                              x => x.SearchProviders.SingleOrDefault(indexer => indexer.Name == _localConfig.InternalSearcher));
            if (_internalSearcher == null)
            {
                LogHelper.Warn<ExamineDemandBuilder>("Could not load UmbracoInternalSearcher, the configuration section could not be read.");
                CanBuild = false;
                return;
            }                

            //get the internal index set to use for the searcher/indexer
            _internalIndexSet = configMgr.GetFirstPluginSetting<IndexSets, IndexSet>("examine/examine.indexes",
                                                                                x => x.SingleOrDefault(set => set.SetName == _localConfig.InternalIndexSet));
            if (_internalIndexSet == null)
            {
                LogHelper.Warn<ExamineDemandBuilder>("Could not load UmbracoInternalIndexSet, the configuration section could not be read.");
                CanBuild = false;
                return;
            }

            CanBuild = true;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProviderBootstrapper"/> class if sufficient configuration information has been supplied by the user.
        /// </summary>
        /// <param name="existingConfig">The existing config.</param>
        /// <param name="examineManager"></param>
        /// <param name="frameworkContext"></param>
        /// <remarks></remarks>
        public ProviderBootstrapper(ProviderConfigurationSection existingConfig, ExamineManager examineManager, IFrameworkContext frameworkContext)
        {
            _existingConfig = existingConfig;
            _examineManager = examineManager;
            _frameworkContext = frameworkContext;

            //bind to all of the Examine events
            foreach (var i in _examineManager.IndexProviderCollection.OfType<BaseIndexProvider>())
            {
                i.IndexingError += (sender, e) => LogHelper.Error<Exception>("[Examine] " + e.Message, e.InnerException);
                i.IndexDeleted += (sender, e) => LogHelper.TraceIfEnabled<ExamineManager>("[Examine] Item {0} has been removed from the index", () => e.DeletedTerm.Value);
                i.NodeIndexed += (sender, e) => LogHelper.TraceIfEnabled<ExamineManager>("[Examine] Item {0} has been indexed", () => e.Item.Id);
            }
        }