public static Frame[] Deserialize(Reader reader) { bufferFrames.Clear(); int length = reader.ReadInt(); int lastSavedFrame = -1; while (reader.Position < reader.Length) { int frameCount = reader.ReadInt(); ushort commandCount = reader.ReadUShort(); Frame frame = new Frame(); for (int i = 0; i < commandCount; i++) { Command com = new Command(); int reconstructionCount = (com.Reconstruct(reader.Source, reader.Position)); reader.MovePosition(reconstructionCount); frame.AddCommand(com); } for (int i = lastSavedFrame + 1; i < frameCount; i++) { bufferFrames.Add(new Frame()); } bufferFrames.Add(frame); lastSavedFrame = frameCount; } for (int i = lastSavedFrame + 1; i < length; i++) { bufferFrames.Add(new Frame()); } return(bufferFrames.ToArray()); }
public void Read(Reader reader) { int move = this.Reconstruct(reader.Source, reader.Position); reader.MovePosition(move); }