Example #1
0
        public BrokerEgressConfigurator AddApi([NotNull] Action <EgressApiConfigurator> configurator)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var configuration = new EgressApiConfiguration();

            _configuration.AddApi(configuration);
            configurator(new EgressApiConfigurator(configuration));
            return(this);
        }
Example #2
0
        /// <summary>
        /// Adds an egress API configuration.
        /// </summary>
        /// <param name="configuration">
        /// The egress API configuration to add.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The egress API configuration is not specified.
        /// </exception>
        /// <exception cref="PoezdConfigurationException">
        /// The same API configuration object or an API with the same ID already present in the list.
        /// </exception>
        public void AddApi([NotNull] EgressApiConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (_apis.Contains(configuration))
            {
                throw new PoezdConfigurationException(
                          $"You try to add an egress API {configuration.Id} which already present in the list of APIs. It's not allowed.");
            }

            // ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local
            if (_apis.Any(api => api.Id.Equals(configuration.Id, StringComparison.InvariantCulture)))
            {
                throw new PoezdConfigurationException(
                          $"An egress API with ID '{configuration.Id}' already present in the list of APIs. Every API should have an unique ID.");
            }

            _apis.Add(configuration);
        }
Example #3
0
 /// <summary>
 /// Constructs a new instance of an egress API configurator.
 /// </summary>
 /// <param name="configuration">
 /// The egress API configuration to configure with this configurator.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// The egress API configuration is not specified.
 /// </exception>
 public EgressApiConfigurator([NotNull] EgressApiConfiguration configuration)
 {
     _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
 }