public FolderWatcherManager(IFolderWatcher watcher, FileFollowerManager manager, CancellationToken token) { wait = () => { const int _5_seconds = 5000; Task taskDelay = null; try { taskDelay = Task.Delay(_5_seconds, token); taskDelay.Wait(); return(true); } catch { return(false); } finally { if (taskDelay != null) { taskDelay.Dispose(); } } }; act = () => { foreach (var path in watcher.FilteredFiles) { manager.Watch(path); if (token.IsCancellationRequested) { return(false); } } return(true); }; }
void AssertWatchTriggeredBy(Action action) { bool called = false; watcher = new FolderWatcher(path => called = true); WatchAction(action); Assert.IsTrue(called); }
public void Release(IFolderWatcher folderWatcher) { var disposableInstance = folderWatcher as IDisposable; if (disposableInstance != null) { disposableInstance.Dispose(); } }
void AssertWatchTriggeredBy(Action action) { bool called = false; watcher = new FolderWatcher(path => called = true); WatchAction(action); Assert.IsTrue(called); }
private void InitializeService() { var configuration = new Configuration(); configuration.Load(); var fileSender = new FileSender(configuration); _folderWatcher = new FolderWatcher(configuration, fileSender); }
public ExampleService(ILogger logger, KxClient client, IFolderWatcher folderWatcher, IOptions <DocumentTypeConfiguration> documentTypeConfiguration, IVirtualUserConnector virtualUserConnector, IBaseMongoRepository repository, IOptions <ProcessDocumentConfiguration> timerconfig) { this.logger = logger; this.client = client; this.folderWatcher = folderWatcher; this.virtualUserConnector = virtualUserConnector; this.repository = repository; this.timerconfig = timerconfig.Value; this.documentTypeConfig = documentTypeConfiguration.Value; typesToArchive = documentTypeConfig.ToArchive; typesToSendToVu = documentTypeConfig.ToSendToVirtualUser; }
private void Initialize(string folder, Func <string, IRepository> repositoryFactory, Func <string, IFolderWatcher> folderWatcherFactory) { _repository = repositoryFactory(folder); _folderWatcher = folderWatcherFactory(folder); _folderWatcher.OnNext += UpdateStatus; // _repository.Info.Path returns a path ending with '\' GitDir = _repository.Info.Path.Substring(0, _repository.Info.Path.Length - 1); CurrentWorkingDirectory = Path.GetFullPath(Path.Combine(GitDir, "..")); UpdateStatus(CurrentWorkingDirectory); }
/// <summary> /// Initializes a new instance of the <see cref="HomeWindowViewModel"/> class. /// </summary> public HomeWindowViewModel(IUpdateMessagesListTask updateMessagesListTask, IMessageMediator mediator, IPleaseWaitService pleaseWaitService, IFolderWatcher folderWatcher, ITryFindParent tryFindParent, IOpenEmailFile openEmailFile) { this.updateMessagesListTask = updateMessagesListTask; this.mediator = mediator; this.pleaseWaitService = pleaseWaitService; this.folderWatcher = folderWatcher; this.tryFindParent = tryFindParent; this.openEmailFile = openEmailFile; RowDoubleClick = new Command <MouseButtonEventArgs>(OnRowDoubleClickExecute, OnRowDoubleClickCanExecute); CheckMessagesCommand = new AsynchronousCommand(OnCheckMessagesCommandExecute, () => !CheckMessagesCommand.IsExecuting); MarkAsReadCommand = new Command <MessageModel>(OnMarkAsReadCommandExecute); ImageSingleClick = new Command <MessageModel>(OnImageSingleClickExecute); Messages = new InitialLoadCommand().Load(); CheckMessagesWithWaiting(); }
public FileSystemMonitorService( FileSystemMonitorServiceConfiguration configuration, IFolderWatcherFactory folderWatcherFactory, FileServiceFactory jobManagerFactory, SynchronizationServiceFactory synchronizationServiceFactory, ILogger logger) { _logger = logger; _folderWatcherFactory = folderWatcherFactory; _folderWatcher = folderWatcherFactory.Create(configuration.FolderToMonitor); _jobManagerFactory = jobManagerFactory; _synchronizationServiceFactory = synchronizationServiceFactory; _configuration = configuration; _serviceShutdownEvent = new ManualResetEventSlim(false); _fileProcessingRoutine = new Task(this.RunServiceOperation, TaskCreationOptions.LongRunning); _operationQueue = new Queue<FileSystemWatcherEventArgs>(); this.SubscribeToEvents(); this.InitializeServiceState(configuration); }
public MainViewModel(IFolderWatcher folderWatcher) { Files = new ObservableCollection<StockFile>(); _folderWatcher = folderWatcher; _folderWatcher.FileFound += (e, args) => _dispatcher.Invoke(() => Files.Add(args.File)); }
public void Release(IFolderWatcher folderWatcher) { _logger.Log(LogLevel.Trace, "Releasing folder watcher."); _folderWatcherFactory.Release(folderWatcher); }
public MainViewModel(IFolderWatcher folderWatcher) { Files = new ObservableCollection <StockFile>(); _folderWatcher = folderWatcher; _folderWatcher.FileFound += (e, args) => _dispatcher.Invoke(() => Files.Add(args.File)); }
public FilmProcessingWatcher(Func <Action <string>, IFolderWatcher> watcherFactory, IFilmProcessor filmProcessor) { Watcher = watcherFactory(path => OnChangeAction(path, filmProcessor)); }