Пример #1
0
        public MainWindowModel(
            ISelectExecuteFileService selectExecuteFileService,
            IShortcutService shortcutService,
            IDialogService dialogService,
            IOpenExolorerService openExolorerService)
        {
            _selectExecuteFileService = selectExecuteFileService;
            _shortcutService          = shortcutService;
            _dialogService            = dialogService;
            _openExolorerService      = openExolorerService;

            _wathcer = new FileSystemWatcher(StartupPath, "*.*")
            {
                EnableRaisingEvents = true
            };
            StartupShortcuts = new[]
            {
                _wathcer.CreatedAsObservable(),
                    _wathcer.ChangedAsObservable(),
                    _wathcer.DeletedAsObservable(),
                    _wathcer.RenamedAsObservable()
            }
            .Merge()
            .Select(_ => GetStartupShorcuts())
            .ToReadOnlyReactivePropertySlim(GetStartupShorcuts());
        }
Пример #2
0
        //public FileWatcher(BlockingCollection<IQueueingData> bc) : this()
        //{
        //    BlockingCollection = bc;
        //}
        public FileWatcher(string path = @"C:\Users\takan\OneDrive\ドキュメント\Visual Studio 2017\Projects\TextDiffDetector\test\")
        {
            previousLength = 0;
            WatchingPath   = path;
            watcher        = new FileSystemWatcher()
            {
                Path         = WatchingPath,
                NotifyFilter =
                    (
                        //    System.IO.NotifyFilters.LastAccess
                        //    System.IO.NotifyFilters.FileName,
                        //    System.IO.NotifyFilters.DirectoryName,
                        NotifyFilters.CreationTime |
                        NotifyFilters.LastWrite),
                Filter = "",    // 全て
                // SynchronizingObject = this   // UIのスレッドにマーシャリングする時に必要 /コンソールアプリケーションでの使用では必要ない
                IncludeSubdirectories = false
            };
            //イベントハンドラの追加
            // Rxを使用することで、イベント集約
            watcher.ChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))          // 一秒内のイベントに集約→一秒内に複数回イベントがあっても一回のイベントに。(実際に複数あったら消えるが、あり得ないと判断)
            .Subscribe(e => DetectDifference(e));

            //監視を開始する
            watcher.EnableRaisingEvents = true;
            //Console.WriteLine("監視を開始しました。");
        }
Пример #3
0
 private RecipeWatcher(string path)
 {
     WatchingPath      = path;
     RecipeFileWatcher = new FileSystemWatcher()
     {
         Path         = WatchingPath,
         NotifyFilter =
             (
                 //    System.IO.NotifyFilters.LastAccess
                 //    System.IO.NotifyFilters.FileName,
                 //    System.IO.NotifyFilters.DirectoryName,
                 NotifyFilters.CreationTime |
                 NotifyFilters.LastWrite),
         Filter = "",    // 全て
         // SynchronizingObject = this   // UIのスレッドにマーシャリングする時に必要 /コンソールアプリケーションでの使用では必要ない
         IncludeSubdirectories = false
     };
     //イベントハンドラの追加
     // Rxを使用することで、イベント集約
     RecipeFileWatcher.ChangedAsObservable()
     .Throttle(TimeSpan.FromSeconds(1))          // 一秒内のイベントに集約→一秒内に複数回イベントがあっても一回のイベントに。(実際に複数あったら消えるが、あり得ないと判断)
     .Subscribe(e => DetectDifference(e));
 }