Exemplo n.º 1
0
        protected ServerWatcher(string name, ServerWatcherConfiguration configuration)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentException("Watcher name can not be empty.");

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration),
                    "Server watcher configuration has not been provided.");
            }

            Name = name;
            _configuration = configuration;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Extension method for adding the Server watcher to the the WardenConfiguration.
        /// </summary>
        /// <param name="builder">Instance of the Warden configuration builder.</param>
        /// <param name="name">Name of the ServerWatcher.</param>
        /// <param name="configuration">Configuration of ServerWatcher.</param>
        /// <param name="hooks">Optional lambda expression for configuring the watcher hooks.</param>
        /// <param name="interval">Optional interval (5 seconds by default) after which the next check will be invoked.</param>
        /// <returns>Instance of fluent builder for the WardenConfiguration.</returns>
        public static WardenConfiguration.Builder AddServerWatcher(
            this WardenConfiguration.Builder builder,
            string name,
            ServerWatcherConfiguration configuration,
            Action<WatcherHooksConfiguration.Builder> hooks = null,
            TimeSpan? interval = null)
        {
            builder.AddWatcher(ServerWatcher.Create(name, configuration), hooks, interval);

            return builder;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Factory method for creating a new instance of ServerWatcher with default name of Server watcher.
 /// </summary>
 /// <param name="configuration">Configuration of ServerWatcher.</param>
 /// <returns>A ServerWatcher instance.</returns>
 public static ServerWatcher Create(ServerWatcherConfiguration configuration)
     => new ServerWatcher(DefaultName, configuration);
Exemplo n.º 4
0
 /// <summary>
 /// Factory method for creating a new instance of ServerWatcher.
 /// </summary>
 /// <param name="name">Name of the ServerWatcher.</param>
 /// <param name="configuration">Configuration of ServerWatcher.</param>
 /// <returns>A ServerWatcher instance.</returns>
 public static ServerWatcher Create(string name, ServerWatcherConfiguration configuration)
     => new ServerWatcher(name, configuration);