示例#1
0
        public void BeginCompoundDo(int pointerIndex)
        {
            if (tempMemento != null)
            {
                throw new InvalidOperationException("Previous complex memento wasn't commited.");
            }

            tempMemento = new CompoundListMemento <T, U>(pointerIndex);
        }
示例#2
0
        public void EndCompoundDo()
        {
            if (tempMemento == null)
            {
                throw new InvalidOperationException("Ending a non-existing complex memento");
            }

            _Do(tempMemento);
            tempMemento = null;
        }
示例#3
0
        public CompoundListMemento <T, U> Restore(T target)
        {
            CompoundListMemento <T, U> inverse = new CompoundListMemento <T, U>(pointerIndex);

            //starts from the last action
            for (int i = mementos.Count - 1; i >= 0; i--)
            {
                inverse.Add(mementos[i].Restore(target));
            }
            return(inverse);
        }