?????????????????л????????????????????ConfiguationProvider?????????????JSON?????JsonConfiguationProvider?????XML?????XmlConfiguationProvider??????INI?????IniConfiguationProvider????????????????????JSON??XML??INI???????JSON??????ü?????????????в?????????????????????????ú?????
??????
????MemoryConfigurationProvider
????EnvironmentVariablesConfigurationProvider
????CommandLineConfigurationProvider
????JsonConfigurationProvider
????XmlConfiguationProvider
????IniConfigurationProvider
?????????ConfigurationProvider
???????JsonConfiguationProvider
????????????????????????JSON????У???????JsonConfiguationProvider??????????????JSON?????????????????????????????乩?????????á?JsonConfiguationProvider??????“Microsoft.Extensions.Configuration.Json”?????£?????????????NuGet?????????
????1: public class JsonConfigurationProvider : ConfigurationProvider
????2: {
????3:     public JsonConfigurationProvider(string path);
????4:     public JsonConfigurationProvider(string path?? bool optional);
????5:
????6:     public override void Load();
????7:
????8:     public string    Path { get; }
????9:     public bool      Optional { get; }
????10: }
??????????????????????JsonConfiguationProvider????????????????Path??Optional????????????????????????JSON???????·????????????????JsonConfiguationProvider?????????ConfigurationProvider?????????False?????Optional?True???????JsonConfiguationProvider??????????????????????????????????????????????????????????????????????
?????????JsonConfiguationProvider?????????????????????????????Add?????????????????ConfigurationBuilder??С??????????????ConfigurationBuilder??????????????????????????AddJsonFile???????????
????1: public static class JsonConfigurationExtensions
????2: {
????3:     public static IConfigurationBuilder AddJsonFile(this IConfigurationBuilder configurationBuilder?? string path);
????4:     public static IConfigurationBuilder AddJsonFile(this IConfigurationBuilder configurationBuilder?? string path?? bool optional);
????5: }
?????????JSON?????????????????????????????????????????????????????????????????????JSON????????????????????????????????????漲???Profile?????????????????????????????????JSON?????????????????Profile???????Profile??????????????Key??Value??????????????Profile?????
????Profile.json
????1: {
????2:   "profile": {
????3:     "gender"  : "Male"??
????4:     "age"     : "18"??
????5:     "contactInfo": {
????6:       "email"        : "foobar@outlook.com"??
????7:       "phoneNo"      : "123456789"
????8:     }
????9:   }
????10: }
????ProfileCollection.json
1: {
2:   "profiles": [
3:     {
4:       "gender"       : "Male"??
5:       "age"          : "18"??
6:       "contactInfo": {
7:         "email"      : "foo@outlook.com"??
8:         "phoneNo"    : "123"
9:       }
10:     }??
11:     {
12:       "gender" : "Male"??
13:       "age"   : "25"??
14:       "contactInfo": {
15:         "email"      : "bar@outlook.com"??
16:         "phoneNo"    : "456"
17:       }
18:     }??
19:     {
20:       "gender" : "Female"??
21:       "age"   : "40"??
22:       "contactInfo": {
23:         "email"      : "baz@outlook.com"??
24:         "phoneNo"    : "789"
25:       }
26:     }
27:   ]
28: }