internal void DoSnapshot(UndoSnapshot snapshot) { if (snapshot.unmanagedData != null) { var stream = new MemoryStream(snapshot.unmanagedData, false); reader = new BinaryReader(stream); } else { reader = null; } managed = snapshot.managedReferences; refId = 0; }
internal UndoSnapshot Build() { byte[] buffer = null; if (stream.Position > 0) { buffer = new byte[stream.Position]; Array.Copy(stream.GetBuffer(), buffer, stream.Position); } var result = new UndoSnapshot(currentTarget, managedRefs.Count > 0 ? managedRefs.ToArray() : null, buffer); stream.Position = 0; managedRefs.Clear(); currentTarget = null; return(result); }
public void RevertToUndoSnapshot(ModelObject target, UndoSnapshot snapshot) { snapshotReader.DoSnapshot(snapshot); ReadUndo(target, snapshotReader); }