Esempio n. 1
0
        /// <summary>
        /// 创建实现了指定接口的HttpApiClient实例
        /// </summary>
        /// <typeparam name="TInterface">请求接口</typeparam>
        /// <param name="httpApiConfig">接口配置</param>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="NotSupportedException"></exception>
        /// <returns></returns>
        public static TInterface Create <TInterface>(HttpApiConfig httpApiConfig) where TInterface : class
        {
            if (httpApiConfig == null)
            {
                httpApiConfig = new HttpApiConfig();
            }

            var interceptor = new ApiInterceptor(httpApiConfig);

            return(HttpApiClientProxy.CreateProxyWithInterface <TInterface>(interceptor));
        }
Esempio n. 2
0
        /// <summary>
        /// 创建实现了指定接口的HttpApiClient实例
        /// </summary>
        /// <param name="interfaceType">请求接口类型</param>
        /// <param name="apiInterceptor">http接口调用拦截器</param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="NotSupportedException"></exception>
        /// <returns></returns>
        public static object Create(Type interfaceType, IApiInterceptor apiInterceptor)
        {
            if (interfaceType == null)
            {
                throw new ArgumentNullException(nameof(interfaceType));
            }

            if (apiInterceptor == null)
            {
                throw new ArgumentNullException(nameof(apiInterceptor));
            }

            return(HttpApiClientProxy.CreateProxyWithInterface(interfaceType, apiInterceptor));
        }