ASP.NET Core???????6??????????????????[???]
???????????? ???????[ 2016/6/23 14:37:43 ] ???????????ù??? ASP.NET
?????????????????л????????????????????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: }
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11