Add afterload event for LoadDefaultConfig

This commit is contained in:
qianlifeng
2014-08-17 15:57:25 +08:00
parent 13e629e17d
commit 49362ce5ab
2 changed files with 10 additions and 7 deletions

View File

@@ -44,7 +44,10 @@ namespace Wox.Infrastructure.Storage
}
}
protected virtual void LoadDefaultConfig() { }
protected virtual T LoadDefaultConfig()
{
return storage;
}
private void Load()
{
@@ -61,19 +64,17 @@ namespace Wox.Infrastructure.Storage
try
{
storage = JsonConvert.DeserializeObject<T>(json);
OnAfterLoadConfig(storage);
}
catch (Exception)
{
//no-op
LoadDefaultConfig();
storage = LoadDefaultConfig();
}
}
else
{
LoadDefaultConfig();
storage = LoadDefaultConfig();
}
OnAfterLoadConfig(storage);
}
public void Save()