/// <summary> /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. /// Adds a handler to be called when changes to section <code>sectionName</code> are detected. /// </summary> /// <param name="sectionName">The name of the section to watch for.</param> /// <param name="handler">The handler.</param> public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { lock (eventHandlersLock) { eventHandlers.AddHandler(sectionName, handler); } }
private void CheckHandler(ConfigurationChangedEventHandler handler) { if (handler == null) { throw new ArgumentNullException("handler"); } }
private void DoNotifyUpdatedSection(string sectionName) { Delegate[] invocationList; lock (eventHandlersLock) { ConfigurationChangedEventHandler callbacks = (ConfigurationChangedEventHandler)eventHandlers[sectionName]; if (callbacks == null) { return; } invocationList = callbacks.GetInvocationList(); } ConfigurationChangedEventArgs eventData = new ConfigurationChangedEventArgs(sectionName); try { foreach (ConfigurationChangedEventHandler callback in invocationList) { if (callback != null) { callback(this, eventData); } } } catch // (Exception e) { //EventLog.WriteEntry(GetEventSourceName(), Resources.ExceptionEventRaisingFailed + GetType().FullName + " :" + e.Message); } }
public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { lock (eventHandlersLock) { eventHandlers.RemoveHandler(CanonicalizeSectionName(sectionName), handler); } }
// must be called outside lock private void NotifyUpdatedSections(IEnumerable <string> sectionsToNotify) { foreach (string sectionName in sectionsToNotify) { ConfigurationChangedEventHandler callbacks = (ConfigurationChangedEventHandler)eventHandlers[sectionName]; if (callbacks == null) { continue; } ConfigurationSqlChangedEventArgs eventData = new ConfigurationSqlChangedEventArgs(this.data.ConnectionString, this.data.GetStoredProcedure, sectionName); try { foreach (ConfigurationChangedEventHandler callback in callbacks.GetInvocationList()) { if (callback != null) { callback(this, eventData); } } } catch // (Exception e) { //EventLog.WriteEntry(GetEventSourceName(), Resources.ExceptionEventRaisingFailed + GetType().FullName + " :" + e.Message); } } }
public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { lock (this.eventHandlersLock) { this.eventHandlers.AddHandler(sectionName, handler); } }
/// <summary> /// Adds a handler to be called when changes to section <code>sectionName</code> are detected. /// This call should always be followed by a <see cref="RemoveSectionChangeHandler"/>. Failure to remove change /// handlers will result in .Net resource leaks. /// </summary> /// <param name="sectionName">The name of the section to watch for.</param> /// <param name="handler">The handler.</param> public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { CheckSectionName(sectionName); CheckHandler(handler); implementation.AddSectionChangeHandler(sectionName, handler); }
public ConfigurationFileSourceWatcher(string configurationFilepath, string configSource, bool refresh, ConfigurationChangedEventHandler changed) : base(configSource, refresh, changed) { this.configurationFilepath = configurationFilepath; if (refresh) { this.SetUpWatcher(changed); } }
private void SetUpWatcher(int refreshInterval, ConfigurationChangedEventHandler changed) { this.configWatcher = new ConfigurationChangeFileWatcher( GetFullFileName(this.configurationFilepath, this.ConfigSource), this.ConfigSource); this.configWatcher.SetPollDelayInMilliseconds(refreshInterval); this.configWatcher.ConfigurationChanged += changed; }
/// <summary> /// Raises the <see cref="ConfigurationSourceHandler.ConfigurationSectionChanged"/> event. /// </summary> /// <param name="sectionName">The name of the section that was changed.</param> protected void DoConfigurationSectionChanged(string sectionName) { ConfigurationChangedEventHandler handler = ConfigurationSectionChanged; if (handler != null) { handler(this, new ConfigurationChangedEventArgs(sectionName)); } }
/// <summary> /// /// </summary> public ConfigurationSqlSourceWatcher(string connectString, string getStoredProc, string configSource, bool refresh, ConfigurationChangedEventHandler changed) : base(configSource, refresh, changed) { this.connectString = connectString; this.getStoredProc = getStoredProc; if (refresh) { SetUpWatcher(changed); } }
public void AddSection(string sectionName, object configurationSection, ConfigurationChangedEventHandler changed, IConfigurationChangeWatcherFactory factory) { lock (lockMe) { if (DoesWatcherExistFor(sectionName) == false) { IConfigurationChangeWatcher watcher = factory.CreateConfigurationChangeWatcher(); AddConfigurationWatcherForSection(changed, watcher); } AddSection(sectionName, configurationSection); } }
internal void DoSourceSectionChanged(string section) { if (DisposeCallCount > 0) { throw new Exception(); } ConfigurationChangedEventHandler handler = SectionChangedHandlers[section] as ConfigurationChangedEventHandler; if (handler != null) { handler(this, new ConfigurationChangedEventArgs(section)); } }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationFileSourceWatcher"/> class. /// </summary> /// <param name="configurationFilepath">The path for the configuration file to watch.</param> /// <param name="configSource">The identification of the configuration source.</param> /// <param name="refresh"><b>true</b> if changes should be notified, <b>false</b> otherwise.</param> /// <param name="refreshInterval">The poll interval in milliseconds.</param> /// <param name="changed">The callback for changes notification.</param> public ConfigurationFileSourceWatcher( string configurationFilepath, string configSource, bool refresh, int refreshInterval, ConfigurationChangedEventHandler changed) : base(configSource, refresh, changed) { this.configurationFilepath = configurationFilepath; if (refresh) { SetUpWatcher(refreshInterval, changed); } }
internal void FireConfigurationSectionChangedNotification(string sectionName) { ConfigurationChangedEventHandler callbacks = (ConfigurationChangedEventHandler)eventHandlers[sectionName]; if (callbacks != null) { ConfigurationChangedEventArgs eventData = new ConfigurationChangedEventArgs(sectionName); foreach (ConfigurationChangedEventHandler callback in callbacks.GetInvocationList()) { if (callback != null) { callback(this, eventData); } } } }
protected virtual void OnConfigurationChanged() { ConfigurationChangedEventHandler callbacks = (ConfigurationChangedEventHandler)eventHandlers[configurationChangedKey]; ConfigurationChangedEventArgs eventData = new ConfigurationChangedEventArgs(Path.GetFullPath(configFilePath), configurationSectionName); try { if (callbacks != null) { callbacks(this, eventData); } } catch (Exception e) { EventLog.WriteEntry(eventSourceName, SR.ExceptionEventRaisingFailed + ":" + e.Message); } }
public void NotifyUpdatedSections(IEnumerable <string> sectionsToNotify) { foreach (string rawSectionName in sectionsToNotify) { String sectionName = CanonicalizeSectionName(rawSectionName); Delegate[] invocationList = null; lock (eventHandlersLock) { ConfigurationChangedEventHandler callbacks = (ConfigurationChangedEventHandler)eventHandlers[sectionName]; if (callbacks == null) { continue; } invocationList = callbacks.GetInvocationList(); } ConfigurationChangedEventArgs eventData = new ConfigurationChangedEventArgs(sectionName); foreach (ConfigurationChangedEventHandler callback in invocationList) { try { if (callback != null) { callback(this, eventData); } } catch (Exception e) { ManageabilityExtensionsLogger.LogException(e, String.Format(Resources.Culture, Resources.ExceptionErrorOnCallbackForSectionUpdate, sectionName, callback.ToString())); } } } }
/// <summary> /// <para>Raises the <see cref="ConfigurationChanged"/> event.</para> /// </summary> protected virtual void OnConfigurationChanged() { ConfigurationChangedEventHandler callbacks = (ConfigurationChangedEventHandler)eventHandlers[configurationChangedKey]; ConfigurationChangedEventArgs eventData = this.BuildEventData(); try { if (callbacks != null) { foreach (ConfigurationChangedEventHandler callback in callbacks.GetInvocationList()) { if (callback != null) { callback(this, eventData); } } } } catch (Exception e) { LogException(e); } }
/// <summary> /// <para> /// Reads configuration settings for a user-defined configuration section. /// </para> /// </summary> /// <param name="sectionName"> /// <para>The configuration section to read.</para> /// </param> /// <returns> /// <para>The configuration settings for <paramref name="sectionName"/>.</para> /// </returns> /// <exception cref="ArgumentException"> /// <para><paramref name="sectionName"/>can not be <see langword="null"/> (Nothing in Visual Basic).</para> /// </exception> /// <exception cref="ConfigurationException"> /// <para><paramref name="sectionName"/> is not valid for this configuration.</para> /// </exception> public object ReadConfiguration(string sectionName) { ValidateSection(sectionName); object configurationSection = sections.GetSection(sectionName); if (IsConfigurationSectionCached(configurationSection)) { return(configurationSection); } IStorageProviderReader storageProviderReader = CreateStorageProvider(sectionName); object configurationSettings = storageProviderReader.Read(); if (configurationSettings == null) { return(null); } ITransformer transformer = CreateTransformer(sectionName); if (transformer != null) { configurationSection = transformer.Deserialize(configurationSettings); } else { configurationSection = configurationSettings; } ConfigurationChangedEventHandler changed = new ConfigurationChangedEventHandler(OnExternalConfigurationChanged); sections.AddSection(sectionName, configurationSection, changed, storageProviderReader); return(configurationSection); }
/// <summary> /// Remove a handler to be called when changes to section <code>sectionName</code> are detected. /// </summary> /// <param name="sectionName">The name of the section to watch for.</param> /// <param name="handler">The handler.</param> public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { implementationByConnectionString[data.ConnectionString].RemoveSectionChangeHandler(sectionName, handler); }
void IConfigurationSource.RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { throw new NotImplementedException(); }
/// <summary> /// Adds a handler to be called when changes to section <code>sectionName</code> are detected. /// This call should always be followed by a <see cref="RemoveSectionChangeHandler"/>. Failure to remove change /// handlers will result in .Net resource leaks. /// </summary> /// <param name="sectionName">The name of the section to watch for.</param> /// <param name="handler">The handler.</param> public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { implementationByFilepath[configurationFilepath].AddSectionChangeHandler(sectionName, handler); }
private void SetUpWatcher(ConfigurationChangedEventHandler changed) { this.configWatcher = new ConfigurationChangeFileWatcher(GetFullFileName(this.configurationFilepath, this.ConfigSource), this.ConfigSource); this.configWatcher.ConfigurationChanged += changed; }
public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { throw new NotImplementedException(); }
public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { this.notificationCoordinator.RemoveSectionChangeHandler(sectionName, handler); }
public ConfigurationSourceWatcher(string configSource, bool refresh, ConfigurationChangedEventHandler changed) { this.configurationSource = configSource; this.watchedSections = new List <string>(); }
public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { }
///<summary> /// Removes a change handler from a section. ///</summary> ///<param name="sectionName"> /// The section to remove the handler. /// </param> ///<param name="handler"> /// The handler to remove. /// </param> public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { notificationCoordinator.RemoveSectionChangeHandler(sectionName, handler); }
private void AddConfigurationWatcherForSection(ConfigurationChangedEventHandler changed, IConfigurationChangeWatcher watcher) { watcher.ConfigurationChanged += changed; watcher.StartWatching(); ConfigurationWatcherCache.Add(watcher.SectionName, watcher); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationSourceWatcher"/> class. /// </summary> /// <param name="configSource">The identification of the medium.</param> /// <param name="refresh"><b>true</b> if changes should be notified, <b>false</b> otherwise.</param> /// <param name="changed">The callback for changes notification.</param> protected ConfigurationSourceWatcher(string configSource, bool refresh, ConfigurationChangedEventHandler changed) { this.configurationSource = configSource; this.watchedSections = new List<string>(); }
public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { this.notificationCoordinator.AddSectionChangeHandler(sectionName, handler); }
/// <summary> /// Adds a change handler for a section. /// </summary> /// <param name="sectionName"> /// The section to add the handler. /// </param> /// <param name="handler"> /// The handler to add. /// </param> public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { notificationCoordinator.AddSectionChangeHandler(sectionName, handler); }
/// <summary> /// /// </summary> /// <param name="changed"></param> private void SetUpWatcher(ConfigurationChangedEventHandler changed) { this.configWatcher = new ConfigurationChangeSqlWatcher(connectString, getStoredProc, this.ConfigSource); this.configWatcher.ConfigurationChanged += changed; }
/// <summary> /// Removes a handler to be called when changes to section <paramref name="sectionName"/> are detected. /// </summary> /// <param name="sectionName">The name of the watched section.</param> /// <param name="handler">The handler for the change event to remove.</param> public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { implementation.RemoveSectionChangeHandler(sectionName, handler); }
/// <summary> /// Removes a handler to be called when changes to section are detected. /// </summary> /// <param name="sectionName">The name of the watched section.</param> /// <param name="handler">The handler for the change event to remove.</param> public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { throw new NotSupportedException(); }
/// <summary> /// <para> /// Reads configuration settings for a user-defined configuration section. /// </para> /// </summary> /// <param name="sectionName"> /// <para>The configuration section to read.</para> /// </param> /// <returns> /// <para>The configuration settings for <paramref name="sectionName"/>.</para> /// </returns> /// <exception cref="ArgumentException"> /// <para><paramref name="sectionName"/>can not be <see langword="null"/> (Nothing in Visual Basic).</para> /// </exception> /// <exception cref="ConfigurationException"> /// <para><paramref name="sectionName"/> is not valid for this configuration.</para> /// </exception> public object ReadConfiguration(string sectionName) { ValidateSection(sectionName); object configurationSection = sections.GetSection(sectionName); if (IsConfigurationSectionCached(configurationSection)) { return configurationSection; } IStorageProviderReader storageProviderReader = CreateStorageProvider(sectionName); object configurationSettings = storageProviderReader.Read(); if (configurationSettings == null) { return null; } ITransformer transformer = CreateTransformer(sectionName); if (transformer != null) { configurationSection = transformer.Deserialize(configurationSettings); } else { configurationSection = configurationSettings; } ConfigurationChangedEventHandler changed = new ConfigurationChangedEventHandler(OnExternalConfigurationChanged); sections.AddSection(sectionName, configurationSection, changed, storageProviderReader); return configurationSection; }
#pragma warning restore 67 /// <summary> /// Adds a handler to be called when changes to section <code>sectionName</code> are detected. /// This call should always be followed by a <see cref="RemoveSectionChangeHandler"/>. Failure to remove change /// handlers will result in .NET resource leaks. /// </summary> /// <param name="sectionName">The name of the section to watch for.</param> /// <param name="handler">The handler.</param> public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { CheckSectionName(sectionName); CheckHandler(handler); implementation.AddSectionChangeHandler(sectionName, handler); }
/// <summary> /// Remove a handler to be called when changes to section <code>sectionName</code> are detected. /// This class should always follow a call to <see cref="AddSectionChangeHandler"/>. Failure /// to call these methods in pairs will result in .Net resource leaks. /// </summary> /// <param name="sectionName">The name of the section to watch for.</param> /// <param name="handler">The handler.</param> public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { implementationByFilepath[configurationFilepath].RemoveSectionChangeHandler(sectionName, handler); }
/// <summary> /// Initializes a new instance of <see cref="ConfigurationChangedProxy"/> for specified <see cref="ConfigurationChangedEventHandler"/>. /// </summary> /// <param name="action">Event action</param> public ConfigurationChangedProxy(ConfigurationChangedEventHandler action) { EventHandler += action; }
public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { throw new NotImplementedException(); }
/// <summary> /// Adds a handler to be called when changes to section <code>sectionName</code> are detected. /// </summary> /// <param name="sectionName">The name of the section to watch for.</param> /// <param name="handler">The handler.</param> public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { eventHandlers.AddHandler(sectionName, handler); }
public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler) { this.eventHandlers.RemoveHandler(sectionName, handler); }