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();
 }
Beispiel #2
0
        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");
     }
 }
Beispiel #5
0
        protected Watcher(string name, WatcherType type)
        {
            if (name.Empty())
            {
                throw new DomainException("Watcher name not be empty.");
            }

            Name = name;
            Type = type;
        }
Beispiel #6
0
        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;
        }
Beispiel #7
0
 public static Watcher Create(string name, WatcherType type)
     => new Watcher(name, type);
Beispiel #8
0
 public static Watcher Create(string name, WatcherType type)
 => new Watcher(name, type);
Beispiel #9
0
 public static Watcher Create(string name, WatcherType type, string group = null)
 => new Watcher(name, type, group);