using Newtonsoft.Json;
using ConfigHelper = MAX.Framework.Helpers.ConfigHelper;
namespace MAX.Framework.Configs
{
public abstract class ConfigBase
{
[JsonIgnore]
public abstract string ConfigName { get; }
}
///
/// 设置
///
public abstract class ConfigBase : ConfigBase where TConfig : ConfigBase, new()
{
private static TConfig mySelf;//= default(T);
public static TConfig Instance
{
get
{
if (mySelf == null)
{
mySelf = new TConfig();
}
return mySelf;
}
}
public static TConfig LoadConfig()
{
try
{
TConfig config = ConfigHelper.LoadConfig();
mySelf = config;
return mySelf;
}
catch { }
return default;
}
public void SaveConfig()
{
ConfigHelper.SaveConfig(ConfigName, this);
}
}
}