/// <summary> /// 获取请求接口的实现对象 /// </summary> /// <typeparam name="TInterface">请求接口</typeparam> /// <param name="host">服务跟路径,效果与HttpHostAttribute一致</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentException"></exception> /// <returns></returns> public TInterface GetHttpApi <TInterface>(string host) where TInterface : class { if (string.IsNullOrEmpty(host)) { throw new ArgumentNullException(); } if (typeof(TInterface).IsInterface == false) { throw new ArgumentException(typeof(TInterface).Name + "不是接口类型"); } return(HttpApiClient.GeneratoProxy <TInterface>(host, this)); }
/// <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)); }
/// <summary> /// 创建TInterface接口的代理实例 /// </summary> /// <param name="httpApiConfig">httpApi配置</param> /// <returns></returns> protected virtual TInterface CreateHttpApi(HttpApiConfig httpApiConfig) { return(HttpApiClient.Create <TInterface>(httpApiConfig)); }
/// <summary> /// 创建接口的代理实例 /// </summary> /// <returns></returns> object _IHttpApiFactory.CreateHttpApi() { var interceptor = this.activeEntryLazy.Value.Interceptor; return(HttpApiClient.Create(typeof(TInterface), interceptor)); }
/// <summary> /// 创建接口的代理实例 /// </summary> /// <returns></returns> object IHttpApiFactory.CreateHttpApi() { var interceptor = this.lifeTimeInterceptorLazy.Value; return(HttpApiClient.Create(typeof(TInterface), interceptor)); }
/// <summary> /// 获取请求接口的实现对象 /// </summary> /// <typeparam name="TInterface">请求接口</typeparam> /// <exception cref="ArgumentException"></exception> /// <returns></returns> public TInterface GetHttpApi <TInterface>() where TInterface : class { return(HttpApiClient.GeneratoProxy <TInterface>(null, this)); }
/// <summary> /// 调试视图 /// </summary> /// <param name="target">查看的对象</param> public DebugView(HttpApiClient target) : base(target.ApiInterceptor) { }