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; } }
public void Add(object objectToUndoTo, string typeOfObject, MergeType mergeType) { ICloneable cloneableObject = (ICloneable)objectToUndoTo; if (cloneableObject != null) { if (m_CurrentUndoIndex <= 0 || mergeType == MergeType.NotMergable || m_UndoBuffer[m_CurrentUndoIndex].m_TypeOfObject != typeOfObject) { m_CurrentUndoIndex++; } UndoCheckPoint newUndoCheckPoint = new UndoCheckPoint((ICloneable)cloneableObject.Clone(), typeOfObject, mergeType); if (m_CurrentUndoIndex < m_UndoBuffer.Count) { m_UndoBuffer[m_CurrentUndoIndex] = newUndoCheckPoint; } else { m_UndoBuffer.Add(newUndoCheckPoint); } m_LastValidUndoIndex = m_CurrentUndoIndex; } }