Пример #1
0
 public bool ReleaseWatcher( UTRSFileWatchable sender )
 {
     bool ok = false;
     if (_fileWatchers.ContainsKey( sender ))
     {
         _fileWatchers.Remove( sender );
         GC.Collect();
         ok = true;
     }
     return ok;
 }
Пример #2
0
        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);
        }
Пример #3
0
        public bool ReleaseWatcher(UTRSFileWatchable sender)
        {
            bool ok = false;

            if (_fileWatchers.ContainsKey(sender))
            {
                _fileWatchers.Remove(sender);
                GC.Collect();
                ok = true;
            }
            return(ok);
        }
Пример #4
0
 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);
     }
 }
Пример #5
0
 public bool RestartWatcher(UTRSFileWatchable sender)
 {
     return(ChangeWatcherState(sender, true));
 }
Пример #6
0
 public bool PauseWatcher(UTRSFileWatchable sender)
 {
     return(ChangeWatcherState(sender, false));
 }
Пример #7
0
 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 );
     }
 }
Пример #8
0
 public bool RestartWatcher( UTRSFileWatchable sender )
 {
     return ChangeWatcherState( sender, true );
 }
Пример #9
0
 public bool PauseWatcher( UTRSFileWatchable sender )
 {
     return ChangeWatcherState( sender, false );
 }
Пример #10
0
 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;
 }