Exemplo n.º 1
0
            /// <summary>
            /// Configure the hooks that will be common for all of the watchers.
            /// </summary>
            /// <param name="hooks">Lambda expression for configuring the  global (common) watcher hooks.</param>
            /// <returns>Instance of fluent builder for the WardenConfiguration.</returns>
            public Builder SetGlobalWatcherHooks(Action <WatcherHooksConfiguration.Builder> hooks)
            {
                var hooksConfigurationBuilder = new WatcherHooksConfiguration.Builder();

                hooks(hooksConfigurationBuilder);
                _configuration.GlobalWatcherHooks = hooksConfigurationBuilder.Build();

                return(this);
            }
Exemplo n.º 2
0
            /// <summary>
            /// Configure the hooks specific for the Warden.
            /// </summary>
            /// <param name="hooks">Lambda expression for configuring the Warden hooks.</param>
            /// <returns>Instance of fluent builder for the WardenConfiguration.</returns>
            public Builder SetGlobalWatcherHooks(Action <WatcherHooksConfiguration.Builder, IIntegrator> hooks)
            {
                var hooksConfigurationBuilder = new WatcherHooksConfiguration.Builder();

                hooks(hooksConfigurationBuilder, _configuration.IntegratorProvider());
                _configuration.GlobalWatcherHooks = hooksConfigurationBuilder.Build();

                return(this);
            }
Exemplo n.º 3
0
            /// <summary>
            /// Adds the watcher to the collection.
            /// Hooks for this particular watcher can be configured via the lambda expression.
            /// </summary>
            /// <param name="watcher">Instance of IWatcher.</param>
            /// <param name="hooks">Optional lambda expression for configuring the watcher hooks.</param>
            /// <returns>Instance of fluent builder for the WardenConfiguration.</returns>
            public Builder AddWatcher(IWatcher watcher, Action <WatcherHooksConfiguration.Builder> hooks = null)
            {
                var hooksConfiguration = WatcherHooksConfiguration.Empty;

                if (hooks != null)
                {
                    var hooksConfigurationBuilder = new WatcherHooksConfiguration.Builder();
                    hooks(hooksConfigurationBuilder);
                    hooksConfiguration = hooksConfigurationBuilder.Build();
                }

                var watcherConfiguration = WatcherConfiguration.Create(watcher)
                                           .WithHooks(hooksConfiguration)
                                           .Build();

                _configuration.Watchers.Add(watcherConfiguration);

                return(this);
            }