コード例 #1
0
        public ChuangLanSmsTest()
        {
            var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", false, true)
                                .Build();

            _config = configuration.GetSection("SMS:ChuangLan").Get <ChuanglanConfig>();
            _client = new ChuanglanClient(_config);
        }
コード例 #2
0
        public ChuanglanClient(ChuanglanConfig config, Action <Exception> exceptionHandler = null)
        {
            _config           = config ?? throw new ArgumentNullException(nameof(config));
            _chuanglanAccount = config.Account ?? throw new ArgumentNullException(nameof(config.Account));
            _proxy            = WebApiClientCreator.Create(config);

            var globalHandle = ExceptionHandleResolver.ResolveHandler();

            globalHandle     += exceptionHandler;
            _exceptionHandler = globalHandle;
        }
コード例 #3
0
        public static IChuanglanApi Create(ChuanglanConfig config)
        {
            var client = new HttpClient
            {
                Timeout     = TimeSpan.FromMilliseconds(config.Timeout),
                BaseAddress = new Uri(config.Account.ApiUrl)
            };

            var httpConfig = new HttpApiConfig(client);

            return(HttpApi.Create <IChuanglanApi>(httpConfig));
        }