修复首选项文件不存在时的提示信息
This commit is contained in:
@@ -40,12 +40,15 @@ namespace SpineViewer.Utils
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从文件反序列对象, 不会抛出异常
|
/// 从文件反序列对象, 不会抛出异常
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool Deserialize<T>(string path, out T obj)
|
public static bool Deserialize<T>(string path, out T obj, bool quietForNotExist = false)
|
||||||
{
|
{
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
_logger.Error("Json file {0} not found", path);
|
if (!quietForNotExist)
|
||||||
MessagePopupService.Error($"Json file {path} not found");
|
{
|
||||||
|
_logger.Error("Json file {0} not found", path);
|
||||||
|
MessagePopupService.Error($"Json file {path} not found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void LoadPreference()
|
public void LoadPreference()
|
||||||
{
|
{
|
||||||
if (JsonHelper.Deserialize<PreferenceModel>(PreferenceFilePath, out var obj))
|
if (JsonHelper.Deserialize<PreferenceModel>(PreferenceFilePath, out var obj, true))
|
||||||
Preference = obj;
|
Preference = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user