public bool ReleaseWatcher( UTRSFileWatchable sender )
 {
     bool ok = false;
     if (_fileWatchers.ContainsKey( sender ))
     {
         _fileWatchers.Remove( sender );
         GC.Collect();
         ok = true;
     }
     return ok;
 }
        private bool ChangeWatcherState(UTRSFileWatchable sender, bool state)
        {
            bool ok = false;

            if (_fileWatchers.ContainsKey(sender))
            {
                FileSystemWatcher watcher = _fileWatchers[sender];
                watcher.EnableRaisingEvents = state;
                ok = true;
            }
            return(ok);
        }
        public bool ReleaseWatcher(UTRSFileWatchable sender)
        {
            bool ok = false;

            if (_fileWatchers.ContainsKey(sender))
            {
                _fileWatchers.Remove(sender);
                GC.Collect();
                ok = true;
            }
            return(ok);
        }
 public void WatchFile(UTRSFileWatchable sender, string documentPath, string documentName)
 {
     if (!_fileWatchers.ContainsKey(sender))
     {
         var watcher = new FileSystemWatcher();
         watcher.Path         = documentPath;
         watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName |
                                NotifyFilters.DirectoryName;
         // Only watch text files.
         watcher.Filter              = documentName;
         watcher.Changed            += sender.FileChanged;
         watcher.Created            += sender.FileCreated;
         watcher.Deleted            += sender.FileDeleted;
         watcher.Renamed            += sender.FileRenamed;
         watcher.EnableRaisingEvents = true;
         _fileWatchers.Add(sender, watcher);
     }
 }
 public bool RestartWatcher(UTRSFileWatchable sender)
 {
     return(ChangeWatcherState(sender, true));
 }
 public bool PauseWatcher(UTRSFileWatchable sender)
 {
     return(ChangeWatcherState(sender, false));
 }
 public void WatchFile( UTRSFileWatchable sender, string documentPath, string documentName )
 {
     if (!_fileWatchers.ContainsKey( sender ))
     {
         var watcher = new FileSystemWatcher();
         watcher.Path = documentPath;
         watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName |
                                NotifyFilters.DirectoryName;
         // Only watch text files.
         watcher.Filter = documentName;
         watcher.Changed += sender.FileChanged;
         watcher.Created += sender.FileCreated;
         watcher.Deleted += sender.FileDeleted;
         watcher.Renamed += sender.FileRenamed;
         watcher.EnableRaisingEvents = true;
         _fileWatchers.Add( sender, watcher );
     }
 }
 public bool RestartWatcher( UTRSFileWatchable sender )
 {
     return ChangeWatcherState( sender, true );
 }
 public bool PauseWatcher( UTRSFileWatchable sender )
 {
     return ChangeWatcherState( sender, false );
 }
 private bool ChangeWatcherState( UTRSFileWatchable sender, bool state )
 {
     bool ok = false;
     if (_fileWatchers.ContainsKey( sender ))
     {
         FileSystemWatcher watcher = _fileWatchers[sender];
         watcher.EnableRaisingEvents = state;
         ok = true;
     }
     return ok;
 }