Пример #1
0
        /// <summary>
        /// 创建接口的代理实例
        /// </summary>
        /// <returns></returns>
        HttpApiClient IHttpApiFactory.CreateHttpApi()
        {
            var handler       = this.lifeTimeHttpHandlerLazy.Value;
            var httpApiConfig = new LifetimeHttpApiConfig(handler);

            if (this.configOptions != null)
            {
                this.configOptions.Invoke(httpApiConfig);
            }

            if (this.keepCookieContainer == true)
            {
                Interlocked.CompareExchange(ref this.cookieContainer, httpApiConfig.HttpHandler.CookieContainer, null);
                if (httpApiConfig.HttpHandler.CookieContainer != this.cookieContainer)
                {
                    httpApiConfig.HttpHandler.CookieContainer = this.cookieContainer;
                }
            }

            return(HttpApiClient.Create(typeof(TInterface), httpApiConfig));
        }
Пример #2
0
 /// <summary>
 /// 创建TInterface接口的代理实例
 /// </summary>
 /// <param name="httpApiConfig">httpApi配置</param>
 /// <returns></returns>
 protected virtual TInterface CreateHttpApi(HttpApiConfig httpApiConfig)
 {
     return(HttpApiClient.Create <TInterface>(httpApiConfig));
 }
Пример #3
0
        /// <summary>
        /// 创建接口的代理实例
        /// </summary>
        /// <returns></returns>
        object _IHttpApiFactory.CreateHttpApi()
        {
            var interceptor = this.activeEntryLazy.Value.Interceptor;

            return(HttpApiClient.Create(typeof(TInterface), interceptor));
        }
Пример #4
0
        /// <summary>
        /// 创建接口的代理实例
        /// </summary>
        /// <returns></returns>
        object IHttpApiFactory.CreateHttpApi()
        {
            var interceptor = this.lifeTimeInterceptorLazy.Value;

            return(HttpApiClient.Create(typeof(TInterface), interceptor));
        }