优化代码,封装json读取方法

This commit is contained in:
czz_y
2024-09-09 08:46:59 +08:00
parent f0df39d658
commit d3f7d2e07c
5 changed files with 31 additions and 11 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace AntdUIDemo.Utils
{
public static class AppSetting
public class AppSetting
{
private static readonly string configFilePath = "appsettings.json";
+25
View File
@@ -0,0 +1,25 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntdUIDemo.Utils
{
public class ConfigurationHelper
{
public static JObject GetAppSettings(string configFilePath = "appsettings.json")
{
// Read the JSON file
var json = File.ReadAllText(configFilePath);
// Parse the JSON object
var jsonObj = JObject.Parse(json);
// Return the "AppSettings" section
return (JObject)jsonObj["AppSettings"];
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace AntdUIDemo.Utils
{
public static class LoggerHelper
public class LoggerHelper
{
public static readonly Logger Logger = LogManager.GetCurrentClassLogger();
}
+1 -1
View File
@@ -9,7 +9,7 @@ using Microsoft.Win32;
namespace AntdUIDemo.Utils
{
public static class ThemeHelper
public class ThemeHelper
{
public static bool IsLightMode()
{