Exemplo n.º 1
0
        /// <summary>
        /// Factory method for creating a new Warden Manager instance, for which the configuration can be provided via the lambda expression.
        /// </summary>
        /// <param name="warden">Instance of the IWarden.</param>
        /// <param name="configurator">Lambda expression to build the configuration of WardenManager.</param>
        /// <returns>Instance of IWardenManager.</returns>
        public static IWardenManager Create(IWarden warden, Action <WardenManagerConfiguration.Builder> configurator)
        {
            var config = new WardenManagerConfiguration.Builder();

            configurator?.Invoke(config);

            return(Create(warden, config.Build()));
        }
Exemplo n.º 2
0
        internal WardenManager(IWarden warden, WardenManagerConfiguration configuration)
        {
            if (warden == null)
            {
                throw new ArgumentException("Warden instance can not be null.", nameof(warden));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration),
                                                "Warden Manager configuration has not been provided.");
            }

            _warden        = warden;
            _configuration = configuration;
            _commandSource = _configuration.WardenCommandSourceProvider();
            _eventHandler  = _configuration.WardenEventHandlerProvider();
            _logger        = _configuration.WardenLoggerProvider();
            _commandSource.CommandReceivedAsync += async(command) => await HandleCommandAsync(command);
        }
Exemplo n.º 3
0
 public void AddWarden(IWarden warden)
 {
     _wardens[warden.Name] = warden;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Factory method for creating a new Warden Manager instance with provided configuration.".
 /// </summary>
 /// <param name="warden">Instance of the IWarden.</param>
 /// <param name="configuration">Configuration of WardenManager.</param>
 /// <returns>Instance of IWardenManager.</returns>
 public static IWardenManager Create(IWarden warden, WardenManagerConfiguration configuration)
 => new WardenManager(warden, configuration);
 public async Task AddWardenAsync(Guid wardenId, IWarden warden)
 {
     _wardens[wardenId] = warden;
     await Task.CompletedTask;
 }