Beispiel #1
0
 public void OnFileChanged(Action action)
 {
     if (fileWatcher == null)
     {
         fileWatcher = new FileChangedWatcher();
         fileWatcher.WatchFile(RealPath, (newFileName) => onFileChanged.Raise());
     }
     if (alredyWatching.Contains(action) == false)
     {
         alredyWatching.Add(action);
         onFileChanged += action;
     }
 }
Beispiel #2
0
        public void HandleFileChanged()
        {
            tempFile = TempFileUtil.CreateTempXmlFile("FileChangedWatcherTest", "foo.xml", "<derek><zoolander/></derek>");
            using (FileChangedWatcher watcher = new FileChangedWatcher(tempFile))
            {
                watcher.OnFileChanged += new FileSystemEventHandler(FileChanged);

                UpdateFile("<rob><schneider/></rob>");
                Assert.AreEqual(1, filechangedCount);

                UpdateFile("<joseph><conrad/></joseph");
                Assert.AreEqual(2, filechangedCount);
            }
        }
 private void EditorViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == nameof(EditorViewModel.ImageBasePath))
     {
         FileChangedWatcher.SetWatchDirectory(Path.Combine(Model.BasePath, Model.DeviceLayout.ImageBasePath));
         NotifyOfPropertyChange(() => LedImageText);
         UpdateLeds();
     }
     else if (e.PropertyName == nameof(EditorViewModel.SelectedImageLayout))
     {
         NotifyOfPropertyChange(() => LedImageText);
         UpdateLeds();
     }
 }
Beispiel #4
0
        public void HandleFileMove()
        {
            tempFile = TempFileUtil.GetTempFilePath("FileChangedWatcherTest", "foo.xml");
            using (FileChangedWatcher watcher = new FileChangedWatcher(tempFile))
            {
                watcher.OnFileChanged += new FileSystemEventHandler(FileChanged);

                string file = TempFileUtil.CreateTempXmlFile("FileChangedWatcherTest", "bar.xml", "<adam><sandler /></adam>");
                new FileInfo(file).MoveTo(tempFile);

                Assert.IsTrue(monitor.WaitOne(5000, false));
                monitor.Reset();
                Assert.AreEqual(1, filechangedCount);
            }
        }
Beispiel #5
0
 public Parser()
 {
     if (Env.RunningUnitTests)
     {
         return;
     }
     Env.App.Run += async() =>
     {
         var hotkeyFileWatcher = new FileChangedWatcher(Env.Config.HotkeyFile);
         Env.App.Exiting += hotkeyFileWatcher.Dispose;
         hotkeyFileWatcher.TextChanged += text =>
         {
             UpdateHotkeyFile(new HotkeyFile("default", text));
             Run();
         };
         await hotkeyFileWatcher.RaiseChangedEventAsync();
     };
 }