/// <summary>
 /// 添加FeignClients
 /// </summary>
 /// <typeparam name="TFeignBuilder"></typeparam>
 /// <param name="feignBuilder"></param>
 /// <param name="assembly">要扫描的程序集</param>
 /// <param name="lifetime">服务的生命周期</param>
 /// <returns></returns>
 public static TFeignBuilder AddFeignClients <TFeignBuilder>(this TFeignBuilder feignBuilder, Assembly assembly, FeignClientLifetime lifetime)
     where TFeignBuilder : IFeignBuilder
 {
     if (assembly == null)
     {
         return(feignBuilder);
     }
     foreach (var serviceType in assembly.GetTypes())
     {
         FeignClientTypeInfo feignClientTypeInfo = feignBuilder.TypeBuilder.Build(serviceType);
         if (feignClientTypeInfo == null || feignClientTypeInfo.BuildType == null)
         {
             continue;
         }
         feignBuilder.Options.Types.Add(feignClientTypeInfo);
         //FeignClientAttribute feignClientAttribute = serviceType.GetCustomAttribute<FeignClientAttribute>();
         FeignClientAttribute feignClientAttribute = serviceType.GetCustomAttributeIncludingBaseInterfaces <FeignClientAttribute>();
         feignBuilder.AddService(serviceType, feignClientTypeInfo.BuildType, feignClientAttribute.Lifetime ?? lifetime);
         // add fallback
         if (feignClientAttribute.Fallback != null)
         {
             feignBuilder.AddService(feignClientAttribute.Fallback, feignClientAttribute.Lifetime ?? lifetime);
         }
         if (feignClientAttribute.FallbackFactory != null)
         {
             feignBuilder.AddService(feignClientAttribute.FallbackFactory, feignClientAttribute.Lifetime ?? lifetime);
         }
     }
     return(feignBuilder);
 }
 public static TFeignBuilder AddFeignClients <TFeignBuilder>(this TFeignBuilder feignBuilder, Assembly assembly, FeignClientLifetime lifetime)
     where TFeignBuilder : IFeignBuilder
 {
     if (assembly == null)
     {
         return(feignBuilder);
     }
     foreach (var serviceType in assembly.GetTypes())
     {
         Type proxyType = feignBuilder.TypeBuilder.BuildType(serviceType);
         if (proxyType == null)
         {
             continue;
         }
         FeignClientAttribute feignClientAttribute = serviceType.GetCustomAttribute <FeignClientAttribute>();
         feignBuilder.AddService(serviceType, proxyType, feignClientAttribute.Lifetime ?? lifetime);
         // add fallback
         if (feignClientAttribute.Fallback != null)
         {
             feignBuilder.AddService(feignClientAttribute.Fallback, feignClientAttribute.Lifetime ?? lifetime);
         }
         if (feignClientAttribute.FallbackFactory != null)
         {
             feignBuilder.AddService(feignClientAttribute.FallbackFactory, feignClientAttribute.Lifetime ?? lifetime);
         }
     }
     return(feignBuilder);
 }