Info
Version: | 1.2024.327.3 |
Author(s): | SFERA srl |
Last Update: | Wednesday, March 27, 2024 |
.NET Fiddle: | Create the first Fiddle |
NuGet Url: | https://www.nuget.org/packages/SFERA.Helpers.AppSettingsJSON |
Install
Install-Package SFERA.Helpers.AppSettingsJSON
dotnet add package SFERA.Helpers.AppSettingsJSON
paket add SFERA.Helpers.AppSettingsJSON
SFERA.Helpers.AppSettingsJSON Download (Unzip the "nupkg" after downloading)
Dependencies
.NETFramework 4.7
- Microsoft.CSharp(>= 4.5.0)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
- Microsoft.CSharp(>= 4.7.0)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
- Microsoft.CSharp(>= 4.5.0)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
- Microsoft.CSharp(>= 4.5.0)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
- Microsoft.CSharp(>= 4.5.0)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
- Microsoft.CSharp(>= 4.5.0)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
- Microsoft.CSharp(>= 4.7.0)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
- Microsoft.CSharp(>= 4.5.0)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
- Newtonsoft.Json(>= 12.0.3)
- SFERA.Helpers.BaseClass(>= 1.2020.234)
Ideal also for reading connection strings.
Here the code:
Console.WriteLine(SFERA.Helpers.AppSettingsJSON.AppSettings.Get("key1"));
Console.WriteLine(SFERA.Helpers.AppSettingsJSON.AppSettings.Get("key2", "D:\\SFERA.Helpers\\Sample\\appsettings.json"));
Console.WriteLine(SFERA.Helpers.AppSettingsJSON.ConnectionStrings.Get("cn1"));
Console.WriteLine(SFERA.Helpers.AppSettingsJSON.ConnectionStrings.Get("cn2", "D:\\SFERA.Helpers\\Sample\\appsettings.json"));
Here the appsettings.json:
{
"ConnectionStrings": {
"cn1": "Persist Security Info=True;Initial Catalog=mycatalog1;server=server.com;User Id=user;Password=pwd;Max Pool Size=500;",
"cn2": "Persist Security Info=True;Initial Catalog=mycatalog2;server=server.com;User Id=user;Password=pwd;Max Pool Size=500;"
},
"AppSettings": {
"key1": "value1",
"key2": "value2"
}.