namespace Yw.Settings
|
{
|
internal class DMAFileHelper
|
{
|
/// <summary>
|
/// json文件名称
|
/// </summary>
|
internal static string JsonFileName
|
{
|
get
|
{
|
if (string.IsNullOrEmpty(_jsonFileName))
|
{
|
_jsonFileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "paras_dma_settings.json");
|
}
|
return _jsonFileName;
|
}
|
}
|
private static string _jsonFileName = null;
|
|
/// <summary>
|
/// 获取
|
/// </summary>
|
internal static DMAParas Get()
|
{
|
if (_appparas == null)
|
{
|
lock (_locker)
|
{
|
if (_appparas == null)
|
{
|
var json = File.ReadAllText(JsonFileName, Encoding.UTF8);
|
_appparas = JsonHelper.Json2Object<DMAParas>(json);
|
if (_appparas == null)
|
{
|
_appparas = new DMAParas();
|
}
|
}
|
}
|
}
|
return _appparas;
|
}
|
private static DMAParas _appparas = null;
|
private static readonly object _locker = new object();
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <returns></returns>
|
internal static bool Save()
|
{
|
if (_appparas == null)
|
{
|
return default;
|
}
|
var json = JsonHelper.Object2FormatJson(_appparas);
|
File.WriteAllText(JsonFileName, json, Encoding.UTF8);
|
return true;
|
}
|
|
}
|
}
|