Exemplo n.º 1
0
        public KdniaoClientTest(ITestOutputHelper output) : base(output)
        {
            var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", false, true).Build();

            _config = configuration.GetSection("ExpressDelivery:Kdniao").Get <KdniaoConfig>();
            _client = new KdniaoClient(_config);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化一个<see cref="KdniaoClient"/>类型的实例
        /// </summary>
        /// <param name="config">配置</param>
        /// <param name="exceptionHandler">异常处理操作</param>
        public KdniaoClient(KdniaoConfig config, Action <Exception> exceptionHandler = null)
        {
            _config  = config ?? throw new ArgumentNullException(nameof(config));
            _account = config.Account ?? throw new ArgumentNullException(nameof(config.Account));
            _proxy   = HttpApiClient.Create <IKdniaoApi>();

            var globalHandle = ExceptionHandleResolver.ResolveHandler();

            globalHandle     += exceptionHandler;
            _exceptionHandler = globalHandle;
        }