using System;
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;

namespace SimpleConfiguration_final {
    public class Program {
        public void Main(string[] args) {
            // Create default configuration
            var defaultConfig = new Dictionary<string, string> {
                { "Key1", "Value 1 from default" },
                { "Key2", "Value 2 from default" },
                { "Key3", "Value 3 from default" },
                { "Key4", "Value 4 from default" },
                { "Key5", "Value 5 from default" },
                { "Key6", "Value 6 from default" },
                { "Section:KeyA", "Value A from default" },
                { "Section:KeyB", "Value B from default" },
                { "Section:KeyC", "Value C from default" },
                { "Section:KeyD", "Value D from default" },
                { "Section:KeyE", "Value E from default" },
                { "Section:KeyF", "Value F from default" },
                { "SomeKeyWithVeryLongName", "Default value of very long key" }
            };

            // Add configuration sources
            var builder = new ConfigurationBuilder();
            builder.SetBasePath(".");
            builder.AddInMemoryCollection(defaultConfig);
            builder.AddJsonFile("config.json", optional: true);
            builder.AddIniFile("config.ini", optional: true);
            builder.AddXmlFile("config.xml", optional: true);
            builder.AddEnvironmentVariables();
            builder.AddCommandLine(args, new Dictionary<string, string> { { "-x", "SomeKeyWithVeryLongName" } });

            // Read configuration from sources
            var config = builder.Build();

            // Print configuration values
            foreach (var key in defaultConfig.Keys) {
                var value = config[key];
                Console.WriteLine($"{key} = {value}");
            }

        }
    }
}
