protected override void Arrange() { LocalSource = new TestConfigurationSource(); var sectionForLocalSource = Arrange_GetLocalSourceSection(); if (sectionForLocalSource != null) LocalSource.Add(SectionName, sectionForLocalSource); ParentSource = new TestConfigurationSource(); var sectionForParentSource = Arrange_GetParentSourceSection(); if (sectionForParentSource != null) ParentSource.Add(SectionName, sectionForParentSource); HierarchicalSourceHandler = new HierarchicalConfigurationSourceHandler(LocalSource, ParentSource); LocalSource.SetHierarchyHandler(HierarchicalSourceHandler); }
/// <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); }
protected override void Arrange() { base.Arrange(); sourceSection = new ConfigurationSourceSection() {ParentSource = "MissingParentSource"}; var localSource = new TestConfigurationSource(); localSource.Add(ConfigurationSourceSection.SectionName, sourceSection); hierarchicalConfigurationSourceHandler = new HierarchicalConfigurationSourceHandler(localSource); localSource.SetHierarchyHandler(hierarchicalConfigurationSourceHandler); }
public void SetHierarchyHandler(HierarchicalConfigurationSourceHandler handler) { HierarchicalConfigurationSource = handler; HierarchicalConfigurationSource.ConfigurationSectionChanged += new ConfigurationChangedEventHandler(compositeConfigurationSource_ConfigurationSectionChanged); HierarchicalConfigurationSource.ConfigurationSourceChanged += new EventHandler<ConfigurationSourceChangedEventArgs>(CompositeConfigurationSource_ConfigurationSourceChanged); }