/// <summary> /// Initializes a new instance of the <see cref="ConfigurationFileWatcher"/> class. /// </summary> /// <param name="path">The path.</param> private ConfigurationFileWatcher([NotNull] string path) { _eventAction = new BufferedAction(WatcherOnChanged, 100); Path = path; if (!File.Exists(path)) { return; } // ReSharper disable once AssignNullToNotNullAttribute _watcher = new FileSystemWatcher(System.IO.Path.GetDirectoryName(path), System.IO.Path.GetFileName(path)); _watcher.Changed += (s, e) => _eventAction.Run(); _watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size; _watcher.EnableRaisingEvents = true; }
/// <summary> /// Adds the specified logs to storage in batches. /// </summary> /// <param name="logs">The logs to add to storage.</param> /// <param name="token">The token.</param> /// <returns>Task.</returns> /// <exception cref="ObjectDisposedException">The logger has been disposed.</exception> public override Task Add(IEnumerable <Log> logs, CancellationToken token = new CancellationToken()) { BufferedAction <Log> bufferedAction = _bufferedSend; if (bufferedAction == null) { throw new ObjectDisposedException(nameof(EmailLogger)); } foreach (Log log in logs) { bufferedAction.Run(log); } return(TaskResult.Completed); }