Ejemplo n.º 1
0
        public MainViewModel(IDirectorySearchHandler handler, IFolderPathProvider folderPathProvider)
        {
            this.StartSearch = ReactiveCommand.Create(() =>
            {
                var path = folderPathProvider.GetPath();
                if (string.IsNullOrWhiteSpace(path))
                {
                    return;
                }

                this.CancellationTokenSource = new CancellationTokenSource();
                handler.StartHandler(path, this.CancellationTokenSource.Token);
            });

            this.StopSearch = ReactiveCommand.Create(() =>
            {
                if (this.CancellationTokenSource == null || this.CancellationTokenSource.IsCancellationRequested)
                {
                    return;
                }

                this.CancellationTokenSource.Cancel();
            });
        }
 public FolderService(IFolderPathProvider folderPathProvider)
 {
     _folderPathProvider = folderPathProvider;
 }