Example #1
0
        private static void configureMe(WebHostBuilderContext hostingContext, IConfigurationBuilder config)
        {
            var      env   = hostingContext.HostingEnvironment;
            LogLevel level = LogLevel.Information;

            if (env.EnvironmentName == "Development")
            {
                level = LogLevel.Trace;
            }
            config.AddConfigServer(new LoggerFactory().AddConsole(level));
        }
Example #2
0
        public void AddConfigServer_ThrowsIfConfigBuilderNull()
        {
            // Arrange
            IConfigurationBuilder configurationBuilder = null;
            var environment = new HostingEnvironment();

            // Act and Assert
            var ex = Assert.Throws <ArgumentNullException>(() => configurationBuilder.AddConfigServer(environment));

            Assert.Contains(nameof(configurationBuilder), ex.Message);
        }
        private static IConfigurationBuilder DoAddConfigServer(IConfigurationBuilder configurationBuilder, string applicationName, string environmentName, ILoggerFactory logFactory)
        {
            if (configurationBuilder == null)
            {
                throw new ArgumentNullException(nameof(configurationBuilder));
            }

            var settings = new ConfigServerClientSettings()
            {
                Name        = applicationName,
                Environment = environmentName
            };

            return(configurationBuilder.AddConfigServer(settings, logFactory));
        }
Example #4
0
        public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder configurationBuilder, string environment, string applicationName, ILoggerFactory logFactory = null)
        {
            if (configurationBuilder == null)
            {
                throw new ArgumentNullException(nameof(configurationBuilder));
            }

            var settings = new ConfigServerClientSettings()
            {
                Name        = applicationName ?? Assembly.GetEntryAssembly()?.GetName().Name,
                Environment = environment ?? DEFAULT_ENVIRONMENT
            };

            return(configurationBuilder.AddConfigServer(settings, logFactory));
        }
        public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder configurationBuilder, IHostingEnvironment environment, ILoggerFactory logFactory = null)
        {
            if (configurationBuilder == null)
            {
                throw new ArgumentNullException(nameof(configurationBuilder));
            }

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

            var settings = new ConfigServerClientSettings()
            {
                Name        = environment.ApplicationName,
                Environment = environment.EnvironmentName
            };

            return(configurationBuilder.AddConfigServer(settings, logFactory));
        }
Example #6
0
 public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder configurationBuilder, string environment, ILoggerFactory logFactory = null)
 {
     return(configurationBuilder.AddConfigServer(environment, Assembly.GetEntryAssembly()?.GetName().Name));
 }
Example #7
0
 public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder configurationBuilder, ILoggerFactory logFactory = null)
 {
     return(configurationBuilder.AddConfigServer(DEFAULT_ENVIRONMENT, Assembly.GetEntryAssembly()?.GetName().Name));
 }