public void Add(IUndoData objectToUndoTo, string typeOfObject, MergeType mergeType) { IUndoData cloneableObject = objectToUndoTo; if (cloneableObject != null) { if (currentUndoIndex <= 0 || mergeType == MergeType.NotMergable || undoBuffer[currentUndoIndex].typeOfObject != typeOfObject) { currentUndoIndex++; } UndoCheckPoint newUndoCheckPoint = new UndoCheckPoint(cloneableObject.Clone(), typeOfObject, mergeType); if (currentUndoIndex < undoBuffer.Count) { undoBuffer[currentUndoIndex] = newUndoCheckPoint; } else { undoBuffer.Add(newUndoCheckPoint); } lastValidUndoIndex = currentUndoIndex; } }
internal UndoCheckPoint(IUndoData objectToUndoTo, string typeOfObject, MergeType mergeType) { this.objectToUndoTo = objectToUndoTo; this.typeOfObject = typeOfObject; this.mergeType = mergeType; }