Пример #1
0
        public ReCoreFilter(ReCoreOptions opts, IReCaptchaService verificationService)
        {
            _opts = opts ?? throw new ArgumentNullException(nameof(opts));
            _verificationService = verificationService ?? throw new ArgumentNullException(nameof(verificationService));

            if (string.IsNullOrWhiteSpace(opts.SecretKey))
            {
                throw new Exception(Strings.SECRET_KEY_REQUIRED);
            }
        }
Пример #2
0
        public static IServiceCollection AddReCore(this IServiceCollection services,
                                                   Func <ReCoreOptions, ReCoreOptions> configurationExpression)
        {
            var expr = configurationExpression ?? new Func <ReCoreOptions, ReCoreOptions>(x => x);
            var opts = new ReCoreOptions();

            opts = expr(opts);

            services.AddSingleton(opts);
            services.AddScoped <IReCaptchaService, ReCaptchaService>();
            services.AddScoped <IHttpService, HttpService>();
            return(services);
        }