public static void StartWatcher(WatcherType watcherType, string fileName, IStreamReader streamReader, ISleeper sleeper) { var watcher = CreateWatcherInternal(watcherType, streamReader, sleeper); watcher.Configuration = GetDefaultFileWatcherConfiguration(fileName); AddWatcherToPool(watcher); watcher.Start(); }
protected Watcher(string name, WatcherType type) { if (name.Empty()) throw new DomainException("Watcher name not be empty."); Name = name; Type = type; }
public static void StartWatcher(WatcherType watcherType, FileWatchConfiguration fileWatchConfiguration, IStreamReader streamReader, ISleeper sleeper) { var watcher = CreateWatcherInternal(watcherType, streamReader, sleeper); watcher.Configuration = fileWatchConfiguration; AddWatcherToPool(watcher); watcher.Start(); }
private static IWatcher CreateWatcherInternal(WatcherType watcherType, IStreamReader streamReader, ISleeper sleeper) { switch (watcherType) { case WatcherType.File: return new FileWatcher(streamReader, sleeper); default: throw new NotImplementedException($"Factory method for {watcherType} not implemented"); } }
protected Watcher(string name, WatcherType type) { if (name.Empty()) { throw new DomainException("Watcher name not be empty."); } Name = name; Type = type; }
public void AddWatcher(string name, WatcherType type) { if (name.Empty()) throw new DomainException("Can not add a watcher without a name to the Warden."); var watcher = GetWatcherByName(name); if (watcher != null) throw new DomainException($"Watcher with name: '{name}' has been already added."); _watchers.Add(Watcher.Create(name, type)); UpdatedAt = DateTime.UtcNow; }
public static Watcher Create(string name, WatcherType type) => new Watcher(name, type);
public static Watcher Create(string name, WatcherType type, string group = null) => new Watcher(name, type, group);