/// <summary>
        /// Configures the <see cref="HttpClient"/> of the specified gateway to use an <see cref="IWebProxy"/>
        /// for sending HTTP requests and receiving HTTP responses.
        /// </summary>
        /// <typeparam name="TGateway"></typeparam>
        /// <param name="builder"></param>
        /// <param name="proxyUrl">URL of proxy server.</param>
        /// <param name="userName">Username of proxy server.</param>
        /// <param name="password">Password of proxy server.</param>
        public static IGatewayConfigurationBuilder <TGateway> WithProxy <TGateway>(
            this IGatewayConfigurationBuilder <TGateway> builder,
            Uri proxyUrl,
            string userName,
            string password)
            where TGateway : class, IGateway
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (proxyUrl == null)
            {
                throw new ArgumentNullException(nameof(proxyUrl));
            }
            if (userName == null)
            {
                throw new ArgumentNullException(nameof(userName));
            }
            if (password == null)
            {
                throw new ArgumentNullException(nameof(password));
            }

            return(builder.WithProxy(new WebProxy(proxyUrl)
            {
                Credentials = new NetworkCredential(userName, password)
            }));
        }
        /// <summary>
        /// Configures the options for Parsian Gateway.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="configureOptions">Configuration</param>
        public static IGatewayConfigurationBuilder <ParsianGateway> WithOptions(
            this IGatewayConfigurationBuilder <ParsianGateway> builder,
            Action <ParsianGatewayOptions> configureOptions)
        {
            builder.Services.Configure(configureOptions);

            return(builder);
        }
        /// <summary>
        /// Configures the options for <see cref="FanAvaGateway"/>.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="configureOptions">Configuration</param>
        public static IGatewayConfigurationBuilder<FanAvaGateway> WithOptions(
            this IGatewayConfigurationBuilder<FanAvaGateway> builder,
            Action<FanAvaGatewayOptions> configureOptions)
        {
            builder.Services.Configure(configureOptions);

            return builder;
        }
        /// <summary>
        /// Configures the accounts for <see cref="FanAvaGateway"/>.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="configureAccounts">Configures the accounts.</param>
        ///
        public static IGatewayConfigurationBuilder <FanAvaGateway> WithAccounts(this IGatewayConfigurationBuilder <FanAvaGateway> builder, Action <IGatewayAccountBuilder <FanAvaGatewayAccount> > configureAccounts)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }


            return(builder.WithAccounts(configureAccounts));
        }
        /// <summary>
        /// Configures IranKish gateway options.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="configureOptions"></param>
        public static IGatewayConfigurationBuilder <IranKishGateway> WithOptions(
            this IGatewayConfigurationBuilder <IranKishGateway> builder,
            Action <IranKishGatewayOptions> configureOptions)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.WithOptions(configureOptions));
        }
        /// <summary>
        /// Adds the given <paramref name="factory"/> to services.
        /// It will be used for configuring the <see cref="IranKishGatewayOptions"/>.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="factory"></param>
        /// <param name="serviceLifetime">Lifetime of <paramref name="factory"/>.</param>
        public static IGatewayConfigurationBuilder <IranKishGateway> WithOptionsProvider(
            this IGatewayConfigurationBuilder <IranKishGateway> builder,
            Func <IServiceProvider, IParbadOptionsProvider <IranKishGatewayOptions> > factory,
            ServiceLifetime serviceLifetime)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.WithOptionsProvider <IranKishGateway, IranKishGatewayOptions>(factory, serviceLifetime));
        }
        /// <summary>
        /// Adds the given <typeparamref name="TOptionsProvider"/> to services.
        /// It will be used for configuring the <see cref="IranKishGatewayOptions"/>.
        /// </summary>
        /// <typeparam name="TOptionsProvider"></typeparam>
        /// <param name="builder"></param>
        /// <param name="serviceLifetime">Lifetime of <typeparamref name="TOptionsProvider"/>.</param>
        public static IGatewayConfigurationBuilder <IranKishGateway> WithOptionsProvider <TOptionsProvider>(
            this IGatewayConfigurationBuilder <IranKishGateway> builder,
            ServiceLifetime serviceLifetime)
            where TOptionsProvider : class, IParbadOptionsProvider <IranKishGatewayOptions>
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.WithOptionsProvider <IranKishGateway, IranKishGatewayOptions, TOptionsProvider>(serviceLifetime));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Configures the specified gateway by using an <see cref="IConfiguration"/>.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="configuration">The <see cref="IConfiguration"/> section.</param>
        internal static IGatewayConfigurationBuilder <TGateway> WithConfiguration <TGateway, TGatewayOptions>(
            this IGatewayConfigurationBuilder <TGateway> builder,
            IConfiguration configuration)
            where TGateway : class, IGateway
            where TGatewayOptions : class, new()
        {
            builder.Services.Configure <TGatewayOptions>(configuration);

            AddDataAnnotationsValidator <TGatewayOptions>(builder.Services);

            return(builder);
        }
        /// <summary>
        /// Configures Parbad Virtual gateway options.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="configureOptions"></param>
        public static IGatewayConfigurationBuilder <ParbadVirtualGateway> WithOptions(
            this IGatewayConfigurationBuilder <ParbadVirtualGateway> builder,
            Action <ParbadVirtualGatewayOptions> configureOptions)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.Services.Configure(configureOptions);

            return(builder);
        }
        /// <summary>
        /// Configures the <see cref="HttpClient"/> of the specified gateway to use an <see cref="IWebProxy"/>
        /// for sending HTTP requests and receiving HTTP responses.
        /// </summary>
        /// <typeparam name="TGateway"></typeparam>
        /// <param name="builder"></param>
        /// <param name="proxyUrl">URL of proxy server.</param>
        public static IGatewayConfigurationBuilder <TGateway> WithProxy <TGateway>(
            this IGatewayConfigurationBuilder <TGateway> builder,
            Uri proxyUrl)
            where TGateway : class, IGateway
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (proxyUrl == null)
            {
                throw new ArgumentNullException(nameof(proxyUrl));
            }

            return(builder.WithProxy(new WebProxy(proxyUrl)));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Adds the given <see cref="IParbadOptionsProvider{TGatewayOptions}"/> to <see cref="IServiceCollection"/>.
        /// It will be used for configuring the specified option.
        /// </summary>
        /// <typeparam name="TGateway"></typeparam>
        /// <typeparam name="TGatewayOptions">An option that should be configured to be used by the specified gateway.</typeparam>
        /// <typeparam name="TOptionsProvider">An <see cref="IParbadOptionsProvider{TOptions}"/> that provides and
        /// configures the <typeparamref name="TGatewayOptions"/></typeparam>
        /// <param name="builder"></param>
        /// <param name="serviceLifetime"></param>
        public static IGatewayConfigurationBuilder <TGateway> WithOptionsProvider <TGateway, TGatewayOptions, TOptionsProvider>(
            this IGatewayConfigurationBuilder <TGateway> builder,
            ServiceLifetime serviceLifetime)
            where TGateway : class, IGateway
            where TGatewayOptions : class, new()
            where TOptionsProvider : class, IParbadOptionsProvider <TGatewayOptions>
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            new ParbadOptionsBuilder(builder.Services)
            .AddOptionsUsingProvider <TGatewayOptions, TOptionsProvider>(serviceLifetime);

            AddDataAnnotationsValidator <TGatewayOptions>(builder.Services);

            return(builder);
        }
        /// <summary>
        /// Configures the <see cref="HttpClient"/> of the specified gateway to use an <see cref="IWebProxy"/>
        /// for sending HTTP requests and receiving HTTP responses.
        /// </summary>
        /// <typeparam name="TGateway"></typeparam>
        /// <param name="builder"></param>
        /// <param name="webProxy">The proxy that must be used.</param>
        /// <returns></returns>
        public static IGatewayConfigurationBuilder <TGateway> WithProxy <TGateway>(
            this IGatewayConfigurationBuilder <TGateway> builder,
            IWebProxy webProxy)
            where TGateway : class, IGateway
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (webProxy == null)
            {
                throw new ArgumentNullException(nameof(webProxy));
            }

            builder.WithHttpClient(clientBuilder =>
                                   clientBuilder.ConfigurePrimaryHttpMessageHandler(()
                                                                                    => new HttpClientHandler
            {
                Proxy = webProxy
            }));

            return(builder);
        }
 /// <summary>
 /// Configures IranKish gateway by using an <see cref="IConfiguration"/>.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="configuration">The <see cref="IConfiguration"/> section.</param>
 public static IGatewayConfigurationBuilder <IranKishGateway> WithConfiguration(
     this IGatewayConfigurationBuilder <IranKishGateway> builder,
     IConfiguration configuration)
 {
     return(builder.WithConfiguration <IranKishGateway, IranKishGatewayOptions>(configuration));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Configures Parsian gateway by using an <see cref="IConfiguration"/>.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="configuration">The <see cref="IConfiguration"/> section.</param>
 public static IGatewayConfigurationBuilder <ParsianGateway> WithConfiguration(
     this IGatewayConfigurationBuilder <ParsianGateway> builder,
     IConfiguration configuration)
 {
     return(builder.WithConfiguration <ParsianGateway, ParsianGatewayOptions>(configuration));
 }
 /// <summary>
 /// Configures Mellat gateway by using an <see cref="IConfiguration"/>.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="configuration">The <see cref="IConfiguration"/> section.</param>
 public static IGatewayConfigurationBuilder <MellatGateway> WithConfiguration(
     this IGatewayConfigurationBuilder <MellatGateway> builder,
     IConfiguration configuration)
 {
     return(builder.WithConfiguration <MellatGateway, MellatGatewayOptions>(configuration));
 }