Beispiel #1
0
        public static IHuyiApis Create(HuyiConfig config)
        {
            var client = new HttpClient
            {
                Timeout = TimeSpan.FromMilliseconds(config.Timeout)
            };

            return(HttpApi.Create <IHuyiApis>(new HttpApiConfig(client)));
        }
Beispiel #2
0
        public HuyiClient(HuyiConfig config, Action <Exception> exceptionHandler = null)
        {
            _config  = config ?? throw new ArgumentNullException(nameof(config));
            _account = config.Account ?? throw new ArgumentNullException(nameof(config.Account));
            _proxy   = WebApiClientCreator.Create(config);

            var globalHandle = ExceptionHandleResolver.ResolveHandler();

            globalHandle     += exceptionHandler;
            _exceptionHandler = globalHandle;
        }
Beispiel #3
0
        public HuyiTests()
        {
            var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", false, true)
                                .Build();

            _config = configuration.GetSection("SMS:Huyi").Get <HuyiConfig>();

            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 HuyiClient(_config, SMS.Exceptions.ExceptionHandleResolver.ResolveHandler());
        }