public void Undo(ChangeSet value)
        {
            bool done = false;
            _isWorking = true;
            try
            {
                do
                {
                    ChangeSet changeSet = _undoStack.Pop();

                    if (changeSet == value || _undoStack.Count == 0)
                        done = true;

                    changeSet.Undo();

                    _redoStack.Push(changeSet);
                    RaiseStateChangeEvent();
                } while (!done);
            }
            finally
            {
                _isWorking = false;
            }
        }
        public void BeginChangeSetBatch(string batchDescription)
        {
            if (_isBatch)
                return;

            _batchCounter++;
            _isBatch = true;

            if (_batchCounter == 1)
            {
                _currentBatch = new ChangeSet(batchDescription);
                _undoStack.Push(_currentBatch);
            }
        }
        public void EndChangeSetBatch()
        {
            _batchCounter--;

            if (_batchCounter < 0)
                _batchCounter = 0;

            if (_batchCounter == 0)
            {
                _currentBatch = null;
                _isBatch = false;
            }
        }