Exemplo n.º 1
0
        private CustomConfigurationSource GetCommandLineConfigSource()
        {
            var commandLineConfigSource = new CustomConfigurationSource();

            commandLineConfigSource.Set(SettingsKeys.PlatformName, this.PlatformName);
            commandLineConfigSource.Set(SettingsKeys.PlatformVersion, this.PlatformVersion);
            commandLineConfigSource.Set(SettingsKeys.RuntimePlatformName, this.RuntimePlatformName);
            commandLineConfigSource.Set(SettingsKeys.RuntimePlatformVersion, this.RuntimePlatformVersion);

            // Set the platform key and version in the format that they are represented in other sources
            // (like environment variables and build.env file).
            // This is so that this enables Configuration api to apply the hierarchical config.
            // Example: "--platform python --platform-version 3.6" will win over "PYTHON_VERSION=3.7"
            // in environment variable
            SetPlatformVersion(this.PlatformName, this.PlatformVersion);

            return(commandLineConfigSource);

            void SetPlatformVersion(string platformName, string platformVersion)
            {
                platformName = platformName == "nodejs" ? "node" : platformName;
                var platformVersionKey = $"{platformName}_version".ToUpper();

                commandLineConfigSource.Set(platformVersionKey, platformVersion);
            }
        }
Exemplo n.º 2
0
        public static IConfigurationBuilder AddCustomSource(this IConfigurationBuilder configurationBuilder)
        {
            CustomConfigurationSource customConfigurationSource = new CustomConfigurationSource();

            configurationBuilder.Add(customConfigurationSource);
            return(configurationBuilder);
        }
Exemplo n.º 3
0
        private CustomConfigurationSource GetCommandLineConfigSource()
        {
            var commandLineConfigSource = new CustomConfigurationSource();

            return(commandLineConfigSource);
        }