/// <summary> /// /// </summary> /// <param name="e"></param> private void NotifyConfigChanged(ConfigChangedEventArgs e) { Delegate[] invocationList = null; lock (eventHandlersLock) { ConfigChangedEventHandler handler = eventHandles[e.GetParameter.GroupName] as ConfigChangedEventHandler; if (handler != null) { invocationList = handler.GetInvocationList(); } } try { if (invocationList != null) { foreach (ConfigChangedEventHandler callback in invocationList) { if (callback != null) { callback(this, e); } } } } catch // (Exception e) { //EventLog.WriteEntry(GetEventSourceName(), Resources.ExceptionEventRaisingFailed + GetType().FullName + " :" + e.Message); } }
/// <summary> /// 处理配置文件更改。 /// </summary> /// <param name="sender">事件源。</param> /// <param name="e">包含事件数据的 <see cref="ConfigChangedEventArgs"/>。</param> private void OnConfigChanged(object sender, ConfigChangedEventArgs e) { bool appDomainRestarted = false; if (e.RestartAppDomainOnChange) { appDomainRestarted = FrameworkConfig.RestartAppDomain(); } if (!appDomainRestarted) { RemoveConfigFromCache(e.GetParameter); NotifyConfigChanged(e); } }
/// <summary> /// <para>Raises the <see cref="Changed"/> event.</para> /// </summary> protected virtual void OnChanged() { ConfigChangedEventHandler callbacks = (ConfigChangedEventHandler)_eventHandlers[_configChangedKey]; ConfigChangedEventArgs eventData = this.BuildEventData(); try { if (callbacks != null) { foreach (ConfigChangedEventHandler callback in callbacks.GetInvocationList()) { if (callback != null) { callback(this, eventData); } } } } catch (Exception e) { LogException(e); } }