コード例 #1
0
        public BrokerIngressConfigurator AddApi([NotNull] Action <IngressApiConfigurator> configurator)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var configuration = new IngressApiConfiguration();

            _configuration.AddApi(configuration);
            configurator(new IngressApiConfigurator(configuration));
            return(this);
        }
コード例 #2
0
        /// <summary>
        /// Adds an ingress API configuration.
        /// </summary>
        /// <param name="configuration">
        /// The ingress API configuration to add.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The ingress 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] IngressApiConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (_apis.Contains(configuration))
            {
                throw new PoezdConfigurationException(
                          $"You try to add an ingress 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 ingress API with ID '{configuration.Id}' already present in the list of APIs. Every API should have an unique ID.");
            }

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