public UndoEngine(EditingContext context)
 {
     this.context = context;
     undoBuffer = new List<UndoUnit>(capacity);
     redoBuffer = new List<UndoUnit>(capacity);
     this.undoEngineImpl = this;
 }
 public UndoEngine(EditingContext context)
 {
     this.context        = context;
     undoBuffer          = new List <UndoUnit>(capacity);
     redoBuffer          = new List <UndoUnit>(capacity);
     this.undoEngineImpl = this;
 }
        // CreateImmediateEditingScope - creates a new ImmediateEditingScope which gatters all edits in its  
        // undo unit list. all changes in ImmediateEditingScope appear as a one change and can be 
        // undoned or redoned as a one set.
        internal ImmediateEditingScope CreateImmediateEditingScope(string bookmarkName, ModelTreeManager modelTreeManager)
        {
            Fx.Assert(modelTreeManager != null, "modelTreeManager should not be null.");

            //only one bookmark is supported
            Fx.Assert(this.bookmark == null, "Nested bookmarks are not supported.");

            //create bookmark undo unit, and give it a description
            BookmarkUndoUnit unit = new BookmarkUndoUnit(this.context, modelTreeManager)
            {
                Description = bookmarkName ?? string.Empty,
            };
            //create bookmark, and pass bookmark undo unit to it.
            this.bookmark = new Bookmark(this, unit);
            //switch implementation of AddUndoUnit, Undo, Redo to be delegated through bookmark
            this.undoEngineImpl = bookmark;
            return new ImmediateEditingScope(modelTreeManager, this.bookmark);
        }
        // CreateImmediateEditingScope - creates a new ImmediateEditingScope which gatters all edits in its
        // undo unit list. all changes in ImmediateEditingScope appear as a one change and can be
        // undoned or redoned as a one set.
        internal ImmediateEditingScope CreateImmediateEditingScope(string bookmarkName, ModelTreeManager modelTreeManager)
        {
            Fx.Assert(modelTreeManager != null, "modelTreeManager should not be null.");

            //only one bookmark is supported
            Fx.Assert(this.bookmark == null, "Nested bookmarks are not supported.");

            //create bookmark undo unit, and give it a description
            BookmarkUndoUnit unit = new BookmarkUndoUnit(this.context, modelTreeManager)
            {
                Description = bookmarkName ?? string.Empty,
            };

            //create bookmark, and pass bookmark undo unit to it.
            this.bookmark = new Bookmark(this, unit);
            //switch implementation of AddUndoUnit, Undo, Redo to be delegated through bookmark
            this.undoEngineImpl = bookmark;
            return(new ImmediateEditingScope(modelTreeManager, this.bookmark));
        }