namespace HotelPms.Share.Util
{
public abstract class DictionarySetting
{
public string FileName { get; set; } = string.Empty;
///
/// 設定データ
///
public Dictionary Data { get; set; } = new Dictionary();
///
/// 設定値取得
///
///
///
public string GetValue(string key)
{
return Data[key];
}
///
/// 項目値設定
///
///
///
public void SetValue(string key, string value)
{
Data[key] = value;
}
///
/// 設定保存
///
public void Save()
{
if (File.Exists(FileName)) { File.Delete(FileName); }
CConvert.ToJsonFile(Data, FileName);
}
public abstract void SetDefault();
public void Load()
{
if (File.Exists(FileName))
{
Dictionary? ret = CConvert.ToInstanceFromJsonFile>(FileName);
if (ret != null) { Data = ret; }
}
SetDefault();
}
}
}