mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-11-30 19:08:08 +08:00
37 lines
885 B
C#
37 lines
885 B
C#
using System;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace HandyControlDemo.Data
|
|
{
|
|
internal class GlobalData
|
|
{
|
|
public static void Init()
|
|
{
|
|
if (File.Exists(AppConfig.SavePath))
|
|
{
|
|
try
|
|
{
|
|
var json = File.ReadAllText(AppConfig.SavePath);
|
|
Config = JsonConvert.DeserializeObject<AppConfig>(json);
|
|
}
|
|
catch
|
|
{
|
|
Config = new AppConfig();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Config = new AppConfig();
|
|
}
|
|
}
|
|
|
|
public static void Save()
|
|
{
|
|
var json = JsonConvert.SerializeObject(Config);
|
|
File.WriteAllText(AppConfig.SavePath, json);
|
|
}
|
|
|
|
public static AppConfig Config { get; set; }
|
|
}
|
|
} |