public void FixParameters(AliyunDysmsConfig config) { if (string.IsNullOrWhiteSpace(TemplateCode)) { TemplateCode = config.TemplateCode; } }
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; }
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)); }
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; }
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()); }