Exemplo n.º 1
0
        public static IStandaloneFeignBuilder AddFeignClients(FeignOptions options)
        {
            if (options == null)
            {
                options = new FeignOptions();
            }

            if (options.Lifetime == FeignClientLifetime.Scoped)
            {
                throw new NotSupportedException(nameof(options.Lifetime) + " can not be FeignClientLifetime.Scoped!");
            }

            StandaloneFeignBuilder feignBuilder = _standaloneFeignBuilder;

            feignBuilder.Options = options;
            if (options.Assemblies.Count == 0)
            {
                feignBuilder.AddFeignClients(Assembly.GetEntryAssembly(), options.Lifetime);
            }
            else
            {
                foreach (var assembly in options.Assemblies)
                {
                    feignBuilder.AddFeignClients(assembly, options.Lifetime);
                }
            }
            feignBuilder.AddService(typeof(ILoggerFactory), typeof(DefaultLoggerFactory), FeignClientLifetime.Singleton);
            feignBuilder.AddService(typeof(ICacheProvider), typeof(DefaultCacheProvider), FeignClientLifetime.Singleton);
            feignBuilder.AddService <IFeignOptions>(options);
            return(feignBuilder);
        }
Exemplo n.º 2
0
 static FeignClients()
 {
     _standaloneFeignBuilder = new StandaloneFeignBuilder();
 }