Memento.Mementor.Batch C# (CSharp) Method

Batch() public method

Marks a batch during which all events are combined so that Undo only needs calling once.
Batches cannot be nested. At any point, there must be only one active batch.
public Batch ( System.Action codeBlock ) : void
codeBlock System.Action The code block performing batch change marking.
return void
        public void Batch(Action codeBlock)
        {
            if (!IsTrackingEnabled) return;
            if (codeBlock == null) throw new ArgumentNullException("codeBlock");

            BeginBatch();
            try {
                codeBlock();
            }
            finally {
                // Must not call EndBatch() because CheckPreconditions() might return false
                BaseEvent @event = InternalEndBatch(_undoStack);
                if (@event != null)
                    PerformPostMarkAction(@event);
            }
        }