protected override void Dispose(bool finalize) { if (_configurationChangeWatcher != null) { _configurationChangeWatcher.StopWatching(); _configurationChangeWatcher = null; } }
public ChoFileSourceChangeWatcher(string filePath, string[] otherFileList) { ChoGuard.ArgumentNotNullOrEmpty(filePath, "filePath"); _filePath = filePath; _configurationChangeWatcher = new ChoConfigurationChangeCompositeFileWatcher(_filePath, _filePath, otherFileList); _configurationChangeWatcher.SetConfigurationChangedEventHandler(filePath, OnConfigurationChanged); }
/// <summary> /// Removes a watcher for the configuration source. /// </summary> /// <param name="configSource"> /// The source to remove the watcher. /// </param> public static void RemoveWatcherForConfigSource(IChoConfigurationChangeWatcher configSourceWatcher) { if (_configSourceWatcherMapping.Contains(configSourceWatcher)) { _configSourceWatcherMapping.Remove(configSourceWatcher); configSourceWatcher.Dispose(); ChoProfile.WriteLine(String.Format("Removing Watcher: [{0}]", configSourceWatcher.EventData.ToString())); } }
/// <summary> /// Sets a watcher for a configuration source. /// </summary> /// <param name="configSource"> /// The configuration source to watch. /// </param> public static void SetWatcherForConfigSource(IChoConfigurationChangeWatcher configSourceWatcher) { if (!IsWatchingConfigSource(configSourceWatcher)) { ////configSourceWatcher.ConfigurationChanged += OnConfigurationChanged; _configSourceWatcherMapping.Add(configSourceWatcher); ChoProfile.WriteLine(String.Format("Setting Watcher: [{0}]", configSourceWatcher.EventData.ToString())); } }
private void RefreshDocument() { if (IsXmlFile) { _includeXmlFilePathNodesMap = ExpandIncludes(_xmlDocument, _filePath, _xmlnsManager); } else { _includeXmlFilePathNodesMap = ExpandIncludes(_xmlDocument, null, _xmlnsManager); } foreach (string includeFile in IncludeFiles) { _lastWriteTimeCache.SetValue(includeFile, File.GetLastWriteTime(includeFile)); } if (_watchChange) { _configurationChangeWatcher = new ChoConfigurationChangeCompositeFileWatcher("ChoXmlDocument", _filePath, IncludeFiles); _configurationChangeWatcher.SetConfigurationChangedEventHandler(this, OnFileChanged); } }
/// <summary> /// Event to notify when configuration changes. /// </summary> //public static event ChoConfigurationChangedEventHandler ConfigurationChanged; ///<summary> /// Determines if the configuration source is being watched. ///</summary> ///<param name="configSource"> /// The configuration source. /// </param> ///<returns> /// true if the source is being watched; otherwise, false. /// </returns> public static bool IsWatchingConfigSource(IChoConfigurationChangeWatcher configSourceWatcher) { return(_configSourceWatcherMapping.Contains(configSourceWatcher)); }