public bool TryGet(ISerializable obj) { if (obj == null) { return(false); } int savePos = msgData.Position; try { this.msgData.Seek(0); obj.Decode(msgData); return(true); } catch (Exception e) { Logger.Exception(e); return(false); } finally { this.msgData.Seek(savePos); } }
//从文件中恢复对象 public static void LoadFromStorage(string filePath, ISerializable target) { StorageAdapter storageAdapter = ReadFromFile(filePath); target.Decode(storageAdapter); }