Beispiel #1
0
        public YunpianSmsClient(YunpianConfig config, Action <Exception> exceptionHandler = null)
        {
            _config         = config ?? throw new ArgumentNullException(nameof(config));
            _yunpianAccount = config.Account ?? throw new ArgumentNullException(nameof(config.Account));
            _proxy          = new YunpianClient(_yunpianAccount.ApiKey).Init();

            var globalHandle = ExceptionHandleResolver.ResolveHandler();

            globalHandle     += exceptionHandler;
            _exceptionHandler = globalHandle;
        }
Beispiel #2
0
        public YunpianSmsTests()
        {
            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:Yunpian").Get <YunpianConfig>();
            _client = new YunpianSmsClient(_config, SMS.Exceptions.ExceptionHandleResolver.ResolveHandler());
        }