Esempio n. 1
0
        /// <summary>
        /// 创建实现了指定接口的HttpApiClient实例
        /// </summary>
        /// <param name="interfaceType">请求接口类型</param>
        /// <param name="httpApiConfig">接口配置</param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="NotSupportedException"></exception>
        /// <returns></returns>
        public static object Create(Type interfaceType, HttpApiConfig httpApiConfig)
        {
            if (httpApiConfig == null)
            {
                throw new ArgumentNullException(nameof(httpApiConfig));
            }
            var interceptor = new ApiInterceptor(httpApiConfig);

            return(Create(interfaceType, interceptor));
        }
Esempio n. 2
0
        /// <summary>
        /// 创建请求接口的实例
        /// </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(ProxyGenerator.CreateInterfaceProxyWithoutTarget <TInterface>(interceptor));
        }
Esempio n. 3
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));
        }