示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileBasedConfigurationSource"/> class.
        /// </summary>
        /// <param name="configurationFilepath">The path for the main configuration file.</param>
        /// <param name="refresh"><b>true</b>if runtime changes should be refreshed, <b>false</b> otherwise.</param>
        /// <param name="refreshInterval">The poll interval in milliseconds.</param>
        protected FileBasedConfigurationSource(string configurationFilepath, bool refresh, int refreshInterval)
        {
            this.configurationFilepath = configurationFilepath;
            this.refresh         = refresh && !string.IsNullOrEmpty(configurationFilepath);
            this.refreshInterval = refreshInterval;
            this.refreshLock     = new object();

            this.eventHandlersLock = new object();
            this.eventHandlers     = new EventHandlerList();

            this.watchersLock = new object();
            this.watchedConfigSourceMapping = new Dictionary <string, ConfigurationSourceWatcher>();
            this.watchedSectionMapping      = new Dictionary <string, ConfigurationSourceWatcher>();

            CompositeConfigurationHandler = new CompositeConfigurationSourceHandler(this);
            CompositeConfigurationHandler.ConfigurationSectionChanged += new ConfigurationChangedEventHandler(handler_ConfigurationSectionChanged);
            CompositeConfigurationHandler.ConfigurationSourceChanged  += new EventHandler <ConfigurationSourceChangedEventArgs>(handler_ConfigurationSourceChanged);

            HierarchicalConfigurationHandler = new HierarchicalConfigurationSourceHandler(this);
            HierarchicalConfigurationHandler.ConfigurationSectionChanged += new ConfigurationChangedEventHandler(handler_ConfigurationSectionChanged);
            HierarchicalConfigurationHandler.ConfigurationSourceChanged  += new EventHandler <ConfigurationSourceChangedEventArgs>(handler_ConfigurationSourceChanged);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FileBasedConfigurationSource"/> class.
        /// </summary>
        /// <param name="configurationFilepath">The path for the main configuration file.</param>
        /// <param name="refresh"><b>true</b>if runtime changes should be refreshed, <b>false</b> otherwise.</param>
        /// <param name="refreshInterval">The poll interval in milliseconds.</param>
        protected FileBasedConfigurationSource(string configurationFilepath, bool refresh, int refreshInterval)
        {
            this.configurationFilepath = configurationFilepath;
            this.refresh = refresh && !string.IsNullOrEmpty(configurationFilepath);
            this.refreshInterval = refreshInterval;
            this.refreshLock = new object();

            this.eventHandlersLock = new object();
            this.eventHandlers = new EventHandlerList();

            this.watchersLock = new object();
            this.watchedConfigSourceMapping = new Dictionary<string, ConfigurationSourceWatcher>();
            this.watchedSectionMapping = new Dictionary<string, ConfigurationSourceWatcher>();

            CompositeConfigurationHandler = new CompositeConfigurationSourceHandler(this);
            CompositeConfigurationHandler.ConfigurationSectionChanged += new ConfigurationChangedEventHandler(handler_ConfigurationSectionChanged);
            CompositeConfigurationHandler.ConfigurationSourceChanged += new EventHandler<ConfigurationSourceChangedEventArgs>(handler_ConfigurationSourceChanged);

            HierarchicalConfigurationHandler = new HierarchicalConfigurationSourceHandler(this);
            HierarchicalConfigurationHandler.ConfigurationSectionChanged += new ConfigurationChangedEventHandler(handler_ConfigurationSectionChanged);
            HierarchicalConfigurationHandler.ConfigurationSourceChanged += new EventHandler<ConfigurationSourceChangedEventArgs>(handler_ConfigurationSourceChanged);
        }
 public void SetCompositeHandler(CompositeConfigurationSourceHandler handler)
 {
     CompositeConfigurationSource = handler;
     CompositeConfigurationSource.ConfigurationSectionChanged += new ConfigurationChangedEventHandler(compositeConfigurationSource_ConfigurationSectionChanged);
     CompositeConfigurationSource.ConfigurationSourceChanged += new EventHandler<ConfigurationSourceChangedEventArgs>(CompositeConfigurationSource_ConfigurationSourceChanged);
 }