???????????????????????????????????????????????·???????????????????????????????????????????????????????????????????????????????????????????????????????????Profile???????????????????????????????????????黷????????????????????“Profile”???????????????????????????? EnvironmentVariablesConfigurationProvider?????????????ConfigurationBuilder??????????ú????????Configuration??????????e???????????Profile????
????1: Environment.SetEnvironmentVariable("Profile:Gender"?? "Male");
????2: Environment.SetEnvironmentVariable("Profile:Age"?? "18");
????3: Environment.SetEnvironmentVariable("Profile:ContactInfo:Email"?? "foobar@outlook.com");
????4: Environment.SetEnvironmentVariable("Profile:ContactInfo:PhoneNo"?? "123456789");
????5:
????6: Profile profile = new ConfigurationBuilder()
????7:     .Add(new EnvironmentVariablesConfigurationProvider("Profile:"))
????8:     .Build()
????9:     .Get<Profile>();
?????????EnvironmentVariablesConfigurationProvider??????????????????????????????????Add????????????EnvironmentVariablesConfigurationProvider????????????ConfigurationBuilder??????????????????????????????????AddEnvironmentVariables??
????1: public static class EnvironmentVariablesExtensions
????2: {
????3:     public static IConfigurationBuilder AddEnvironmentVariables(this IConfigurationBuilder configurationBuilder);
????4:     public static IConfigurationBuilder AddEnvironmentVariables(this IConfigurationBuilder configurationBuilder?? string prefix);
????5: }
????????CommandLineConfigurationProvider
????????????£?????????Self-Host?????????ASP.NET Core??ü???????й?????У??????????????????????????????е????????????????????????е??????????ASP.NET Core????????????????????????п????Switch?????????????Щ??????????????п???????????????ó????????????????????????????????????????CommandLineConfigurationProvider??????????????????“Microsoft.Extensions.Configuration.CommandLine”?????У??????????NuGet?????????
?????????????е???????????????????????п??????????????????????????????????????????CommandLineConfigurationProvider??????????????????п???????????????????????????????????????????????????????????????????CommandLineConfigurationProvider?????????п?????????????????????????????????????????????????????п????????????????????????????????“exec”????????????????????????й????app????
????1: exec app {options}
?????????????????????????????????????п????????????????????????????CPUI?????X86????X64??????????????????????CLR????CoreCLR????????????????????п??????????architecture??runtime????????????е??????????????????????????????????????????п????
????1: exec app /architecture x64 /runtime coreclr
????2: exec app --architecture x64 --runtime coreclr
????3: exec app architecture=x64 architecture=coreclr
??????????????????????????п??????????д??????????????????????????п???????????????????????“a”??“r”??????????????“architecture”??“runtime”???????????д???????п??????????????????????????????????CPU???????????????
????1: exec app –-a x64 –-r coreclr
????2: exec app -a x64 -r coreclr
??????????????????????????????????п????????????????????????п????????????μ???????????????п??????д????????????????????????????????????????????д??????????????

????????????п????????????????л???????????????????????????????????????????????????????CommandLineConfigurationProvider??????????????????????????????????????????????????????в????????????CommandLineConfigurationProvider???????????Args??????????????????
????1: public class CommandLineConfigurationProvider : ConfigurationProvider
????2: {
????3:     public CommandLineConfigurationProvider(IEnumerable<string> args?? IDictionary<string?? string> switchMappings = null);
????4:     public override void Load();
????5:
????6:     protected IEnumerable<string> Args { get; }
????7: }
??????????????????????????switchMappings????????????п??????????д?????????????????????????п???????????????????д?????????“architecture”??????д??“a”???????д??“arch”???????????д???????????????п????????????“-”????“--”???????????switchMappings??????????????е?Key?????????????????
?????????CommandLineConfigurationProvider?????????????????????????????Add?????????????????ConfigurationBuilder??С??????????????ConfigurationBuilder??????????????????????????AddCommandLine???????????
????1: public static class CommandLineConfigurationExtensions
????2: {
????3:     public static IConfigurationBuilder AddCommandLine(this IConfigurationBuilder configurationBuilder?? string[] args);
????4:     public static IConfigurationBuilder AddCommandLine(this IConfigurationBuilder configurationBuilder?? string[] args??IDictionary<string?? string> switchMappings);
????5: }
????????????????????????????????????????CommandLineConfigurationProvider???????п????????????????????????????????????????????GetConfigurations?У??????????????????????????????????????в???????????Configuration?????????????????????п????????????Ч???????????????????“architecture”??“runtime”?????????????
1: public class Program
2: {
3:     public static void Main(string[] args)
4:     {
5:         foreach (IConfiguration configuration in GetConfigurations())
6:         {
7:             Debug.Assert(configuration["architecture"] == "x64");
8:             Debug.Assert(configuration["runtime"] == "coreclr");
9:         }
10:     }
11:
12:     private static IEnumerable<IConfiguration> GetConfigurations()
13:     {
14:         yield return new ConfigurationBuilder()
15:          .AddCommandLine(new string[] { "/architecture"?? "x64"?? "/runtime"?? "coreclr" })
16:          .Build();
17:
18:         yield return new ConfigurationBuilder()
19:         .AddCommandLine(new string[] { "--architecture"?? "x64"?? "--runtime"?? "coreclr" })
20:         .Build();
21:
22:         yield return new ConfigurationBuilder()
23:         .AddCommandLine(new string[] { "architecture=x64"?? "runtime=coreclr" })
24:         .Build();
25:
26:         yield return new ConfigurationBuilder()
27:         .AddCommandLine(new string[] { "--a"?? "x64"?? "--r"?? "coreclr" }?? new Dictionary<string?? string>
28:         {
29:             ["--a"] = "architecture"??
30:             ["--r"] = "runtime"
31:         }).Build();
32:
33:         yield return new ConfigurationBuilder()
34:         .AddCommandLine(new string[] { "-a"?? "x64"?? "-r"?? "coreclr" }?? new Dictionary<string?? string>
35:         {
36:             ["-a"] = "architecture"??
37:             ["-r"] = "runtime"
38:         }).Build();
39:     }
40: }
??????????????е???ó???????????????????????????п????????????????????????????????????Options?????????????п?????????????????????????????????????????????????????????????????????????·???????????п????????“/foo:bar:baz abc”????????????????????ü???????????????