Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GatewayMiddleware"/> class.
        /// </summary>
        /// <param name="next">
        /// The next.
        /// </param>
        /// <param name="dispatcherProvider">
        /// The dispatcher provider.
        /// </param>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <exception cref="ArgumentNullException">Either the dispatcher provider or the options is null.</exception>
        public GatewayMiddleware(
            RequestDelegate next,
            HttpRequestDispatcherProvider dispatcherProvider,
            IOptions <GatewayOptions> options)
        {
            if (dispatcherProvider == null)
            {
                throw new ArgumentNullException(nameof(dispatcherProvider));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            this.dispatcherProvider = dispatcherProvider;
            this.options            = options.Value;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the <see cref="HttpRequestDispatcherProvider"/>.
        /// </summary>
        /// <param name="services">
        /// The services.
        /// </param>
        /// <param name="provider">
        /// The provider.
        /// </param>
        /// <returns>
        /// The <see cref="IServiceCollection"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">Either the services or the provider is null.</exception>
        public static IServiceCollection AddHttpRequestDispatcherProvider(
            this IServiceCollection services,
            HttpRequestDispatcherProvider provider)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            services.AddSingleton(provider);

            return(services);
        }