public YuntongxunSmsClient(YuntongxunSmsConfig config, Action <Exception> exceptionHandler = null) { _config = config ?? throw new ArgumentNullException(nameof(config)); _yuntongxunAccount = config.Account ?? throw new ArgumentNullException(nameof(config.Account)); _proxy = _config.Production ? HttpApiClient.Create <ICloopenApis>("https://app.cloopen.com:8883") : HttpApiClient.Create <ICloopenApis>("https://sandboxapp.cloopen.com:8883"); var globalHandle = ExceptionHandleResolver.ResolveHandler(); globalHandle += exceptionHandler; _exceptionHandler = globalHandle; }
public YuntongxunSmsTests() { var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", false, true) .Build(); SMS.Exceptions.ExceptionHandleResolver.SetHandler(e => { var sb = new StringBuilder(); sb.AppendLine(e.Message); sb.AppendLine(e.Source); sb.AppendLine(e.StackTrace); _messageIfError += sb.ToString(); }); _config = configuration.GetSection("SMS:Yuntongxun").Get <YuntongxunSmsConfig>(); _client = new YuntongxunSmsClient(_config, SMS.Exceptions.ExceptionHandleResolver.ResolveHandler()); }