public static PersistentState ReadStream(Stream stream)
{
PersistentState state;
using (var reader = new StreamReader(stream, Encoding.UTF8)) {
try {
state = Serializer.Deserialize(reader) as PersistentState;
} catch(Exception ex) {
state = null;
Log.Error("PersistentState deserialize failed.", ex);
}
}
if(null != state)
state.IsDirty = false;
return state;
}