Exemplo n.º 1
0
        private static void LoadConfiguration(IConfiguration currentConfiguration, IConfigurationBuilder config, string componentPath, CommandLineArgs args)
        {
            Logger.Trace(m => m("Loading hostable component using path [{0}].", componentPath));

            var componentBasePath = Path.GetDirectoryName(componentPath);

            config.SetBasePath(componentBasePath);

            var configName = currentConfiguration[ConfigurationNameEnvVariable];

            Logger.Info(m => m("Application was launched with configuration '{0}'.", configName));

            config.LoadSharedLibraryConfigurationFiles(Logger, componentBasePath, args.SharedLibrariesPath);

            var configProvider = new ConfigFileNamesProvider(configName, componentBasePath, args.SharedLibrariesPath);

            var valuesBuilder = new ConfigurationBuilder();

            foreach (var valuesFile in configProvider.GetTemplateValuesFiles())
            {
                Logger.Trace(m => m($"Loading values file: {valuesFile}"));
                valuesBuilder.AddJsonFile(valuesFile, optional: true, false);
            }

            foreach (var configFile in configProvider.EnumerateConfigFiles())
            {
                config.AddJsonTemplateFile(configFile, false, false, valuesBuilder.Build().Providers, args.PlaceholderPattern);

                Logger.Trace(m => m("Configuration file [{0}] is loaded.", configFile));
            }
        }