public ApiRPCClientProxyInterceptor(IHttpClientFactory httpClientFactory, OpenServiceOptions openServiceOption, Type interfaceType)
 {
     _httpClientFactory = httpClientFactory;
     _openServiceOption = openServiceOption;
     _interfaceType     = interfaceType;
 }
 /// <summary>
 /// 获取客户端
 /// </summary>
 /// <typeparam name="TService">服务接口</typeparam>
 /// <param name="openServiceOption">参数</param>
 /// <returns></returns>
 public TService GetClient <TService>(OpenServiceOptions openServiceOption) where TService : class, IOpenService
 {
     return(GetClient(typeof(TService), openServiceOption) as TService);
 }
 /// <summary>
 /// 获取客户端
 /// </summary>
 /// <param name="interfaceType"></param>
 /// <param name="openServiceOption">参数</param>
 /// <returns></returns>
 internal object GetClient(Type interfaceType, OpenServiceOptions openServiceOption)
 {
     return(_generator.CreateInterfaceProxyWithoutTarget(interfaceType, new ApiRPCClientProxyInterceptor(_httpClientFactory, openServiceOption, interfaceType).ToInterceptor()));
 }
        /// <summary>
        /// OpenService服务
        /// </summary>
        /// <param name="services">容器</param>
        /// <param name="assembly">OpenService服务所在程序集</param>
        /// <param name="openServiceOption">参数</param>
        /// <returns></returns>
        public static IServiceCollection AddOpenServiceClient(this IServiceCollection services, Assembly assembly, OpenServiceOptions openServiceOption)
        {
            services.AddTransient <OpenServiceClientFactory>();

            var interfaces = assembly.GetTypes().Where(x => typeof(IOpenService).IsAssignableFrom(x)).ToList();

            //服务接口注入
            interfaces.ForEach(aInterface =>
            {
                services.AddTransient(aInterface, serviceProvider =>
                {
                    return(serviceProvider.GetService <OpenServiceClientFactory>().GetClient(aInterface, openServiceOption));
                });
            });

            return(services);
        }