Пример #1
0
 public SmsController(
     IOptions <TencentSmsConfig> smsOptions,
     IOptions <TencentSmsTemplateConfig> smsTemplateOptions,
     CydcContext db)
 {
     _smsConfig         = smsOptions.Value;
     _smsTemplateConfig = smsTemplateOptions.Value;
     _db = db;
 }
Пример #2
0
        public TencentSmsTests()
        {
            var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", false, true)
                                .Build();

            _config = configuration.GetSection("SMS:TencentCloud").Get <TencentSmsConfig>();
            _client = new TencentSmsClient(_config);
        }
Пример #3
0
        public TencentSmsClient(TencentSmsConfig config, Action <Exception> exceptionHandler = null)
        {
            _config         = config ?? throw new ArgumentNullException(nameof(config));
            _tencentAccount = config.Account ?? throw new ArgumentNullException(nameof(config.Account));

            _proxy = new TencentSmsSenderProxy(_tencentAccount.AppId, _tencentAccount.AppKey);

            var globalHandle = ExceptionHandleResolver.ResolveHandler();

            globalHandle     += exceptionHandler;
            _exceptionHandler = globalHandle;
        }