mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
null enhance
This commit is contained in:
@@ -64,7 +64,7 @@ namespace Wox.Infrastructure.Storage
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var t = (T)binaryFormatter.Deserialize(stream);
|
var t = ((T)binaryFormatter.Deserialize(stream)).NonNull();
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
|
|||||||
@@ -49,20 +49,25 @@ namespace Wox.Infrastructure.Storage
|
|||||||
{
|
{
|
||||||
LoadDefault();
|
LoadDefault();
|
||||||
}
|
}
|
||||||
return _data;
|
return _data.NonNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Deserialize(string searlized)
|
private void Deserialize(string searlized)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_data = JsonConvert.DeserializeObject<T>(searlized, _serializerSettings).NonNull();
|
_data = JsonConvert.DeserializeObject<T>(searlized, _serializerSettings);
|
||||||
}
|
}
|
||||||
catch (JsonSerializationException e)
|
catch (JsonSerializationException e)
|
||||||
{
|
{
|
||||||
LoadDefault();
|
LoadDefault();
|
||||||
Log.Exception($"|JsonStrorage.Deserialize|Deserialize error for json <{FilePath}>", e);
|
Log.Exception($"|JsonStrorage.Deserialize|Deserialize error for json <{FilePath}>", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_data == null)
|
||||||
|
{
|
||||||
|
LoadDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadDefault()
|
private void LoadDefault()
|
||||||
|
|||||||
Reference in New Issue
Block a user