Feature Request: MaxUndoCountFeature Request: MaxUndoCount
Old forum URL: forums.lhotka.net/forums/t/7118.aspx
Andreas posted on Wednesday, June 17, 2009
Hi,
In some complex UI scenarios I need to call BeginEdit() on a BBL on each ListChangedEvent (which is called when the user changes properties of a item in the list). The event is usually fired from the UI. Depending on how the user acts on the form this can cause hundreds of BeginEdit which needs significant memory resources and causes performance decreases (and probably crashes). For these scenarios I would like to be able to limit the number of undoable object states CSLA maintains for Undo, let’s say MaxUndoCount=50. The result would be that only the last 50 edits/changes can be undone (if needed) through CanelEdit(). Would this make sence?
Andreas
RockfordLhotka replied on Wednesday, June 17, 2009
Wow!
That is definately outside the design goals for n-level undo, and I'm not surprised you have memory issues doing that.
You should feel free to alter your code to do as you suggest, but it isn't something I plan to do in the core framework.
Andreas replied on Thursday, June 18, 2009
Rocky, no problem. I was able to implement the required behaivior outside the framework. But why do you think that my use case "is outside the design goals of n-level Undo? I would apreciate your comment.
Andreas
RockfordLhotka replied on Thursday, June 18, 2009
N-level undo exists to support Cancel buttons and data binding. It is not designed with the idea that you'd have more than a very few levels of undo - probably 3 to 5 levels, maybe as many as 10 for an incredibly complex object model and UI (though I've never come close to 10).Tom_W replied on Thursday, June 18, 2009
[sound of penny dropping]
Oh... I think I finally understand... so the 'n-level' in 'n-level undo' effectively refers to the 'n' depth of the object graph (e.g. for OrderHeader->OrderLinesCollection->OrderLine->LineDetails 'n' is effectively 4) and the need to reverse out all the changes in one go if a Cancel button is pressed?
I'd always read n-level undo as meaning 'n' number of historical states that an unsaved object (or object-graph) could be restored back through. E.g. Visual Studio's undo function in the text editor where you have potentially hundreds of previous versions of the code file that you can undo through. Am I right in saying this isn't what CSLA n-level undo is for?
(you maybe able to tell I'm not using undo successfully in my code yet...!)
RockfordLhotka replied on Thursday, June 18, 2009
The ‘n’ in n-level is the number of complete object
snapshots that are taken. Usually for a root object n will be 1 or 2, and for a
child 1-3 and for a grandchild 1-4, etc.
If you want detail-level undo like Word, you’ll need to
implement that yourself.
Rocky
Copyright (c) Marimer LLC