Exemplo n.º 1
0
        /// <summary>
        /// Adds the HCaptcha configuration <see cref="section"/> as <see cref="HCaptchaOptions"/>.
        /// Adds <see cref="IHCaptchaApi"/> as Refit Client with given base address in <see cref="HCaptchaOptions"/>.
        /// </summary>
        public static IServiceCollection AddHCaptcha(this IServiceCollection services, IConfigurationSection section)
        {
            HCaptchaOptions captchaOptions = new HCaptchaOptions();

            section.Bind(captchaOptions);

            services.Configure <HCaptchaOptions>(section);

            services.AddRefitClient <IHCaptchaApi>()
            .ConfigureHttpClient(c =>
            {
                c.BaseAddress = new Uri(captchaOptions.ApiBaseUrl);
            }
                                 );

            services.AddScoped <IHCaptchaProvider, HCaptchaProvider>();

            return(services);
        }
Exemplo n.º 2
0
 public HCaptchaModelBinder(IHCaptchaProvider captchaProvider, IOptions <HCaptchaOptions> captchaOptionsAccessor)
 {
     _captchaProvider = captchaProvider;
     _captchaOptions  = captchaOptionsAccessor.Value;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates an instance of <see cref="HCaptchaProvider"/>
 /// </summary>
 public HCaptchaProvider(IHCaptchaApi captchaApi, IOptions <HCaptchaOptions> captchaOptionsAccessor)
 {
     _captchaApi     = captchaApi;
     _captchaOptions = captchaOptionsAccessor.Value;
 }