コード例 #1
0
        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;
            }
        }