Exemplo n.º 1
0
 public void FixParameters(AliyunDysmsConfig config)
 {
     if (string.IsNullOrWhiteSpace(TemplateCode))
     {
         TemplateCode = config.TemplateCode;
     }
 }
Exemplo n.º 2
0
        public AliyunDysmsClient(AliyunDysmsConfig config, Action <Exception> exceptionHandler = null)
        {
            _config             = config ?? throw new ArgumentNullException(nameof(config));
            _aliyunDysmsAccount = config.Account ?? throw new ArgumentNullException(nameof(config.Account));
            _proxy = WebApiClientCreator.Create(config);

            var globalHandle = ExceptionHandleResolver.ResolveHandler();

            globalHandle     += exceptionHandler;
            _exceptionHandler = globalHandle;
        }
Exemplo n.º 3
0
        public static IAliyunDysmsApi Create(AliyunDysmsConfig config)
        {
            var client = new HttpClient
            {
                Timeout     = TimeSpan.FromMilliseconds(config.TimeOut),
                BaseAddress = config.Security
                    ? new Uri("https://dysmsapi.aliyuncs.com")
                    : new Uri("http://dysmsapi.aliyuncs.com")
            };

            var httpConfig = new HttpApiConfig(client);

            return(HttpApi.Create <IAliyunDysmsApi>(httpConfig));
        }
Exemplo n.º 4
0
        public AliyunDysmsClient(AliyunDysmsConfig config, Action <Exception> exceptionHandler = null)
        {
            _config             = config ?? throw new ArgumentNullException(nameof(config));
            _aliyunDysmsAccount = config.Account ?? throw new ArgumentNullException(nameof(config.Account));

            _proxy = config.Security
                ? HttpApiClient.Create <IAliyunDysmsApi>("https://dysmsapi.aliyuncs.com")
                : HttpApiClient.Create <IAliyunDysmsApi>("http://dysmsapi.aliyuncs.com");

            var globalHandle = ExceptionHandleResolver.ResolveHandler();

            globalHandle     += exceptionHandler;
            _exceptionHandler = globalHandle;
        }
Exemplo n.º 5
0
        public AliyunDysmsTests()
        {
            var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", false, true)
                                .Build();

            _config = configuration.GetSection("SMS:Aliyun").Get <AliyunDysmsConfig>();

            SMS.Exceptions.ExceptionHandleResolver.SetHandler(e => {
                var sb = new StringBuilder();
                sb.AppendLine(e.Message);
                sb.AppendLine(e.Source);
                sb.AppendLine(e.StackTrace);
                _messageIfError += sb.ToString();
            });

            _client = new AliyunDysmsClient(_config, SMS.Exceptions.ExceptionHandleResolver.ResolveHandler());
        }