增加Prism 框架
This commit is contained in:
1 parent
2cd6b8db86
commit
726eb6de16
99 files changed
+12527
No files matched your search
@@ -0,0 +1,46 @@
|
||||
using Newtonsoft.Json;
|
||||
using ConfigHelper = MAX.Framework.Helpers.ConfigHelper;
|
||||
|
||||
namespace MAX.Framework.Configs
|
||||
{
|
||||
public abstract class ConfigBase
|
||||
{
|
||||
[JsonIgnore]
|
||||
public abstract string ConfigName { get; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置
|
||||
/// </summary>
|
||||
public abstract class ConfigBase<TConfig> : 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<TConfig>();
|
||||
mySelf = config;
|
||||
return mySelf;
|
||||
}
|
||||
catch { }
|
||||
return default;
|
||||
}
|
||||
public void SaveConfig()
|
||||
{
|
||||
ConfigHelper.SaveConfig(ConfigName, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user