Is there any way to reset all previous BeginEdit() operations in one step or do I have to call always CancelEdit() until EditLevel==0?
Sorry, maybe I missed something. But if I don't care about changes and any BeginEdit/ApplyEdit operation on any of the child objects made before? The parent object in my case a BLB and child objects are BB. I am wondering why the framework could not simply restore the first persisted state from the stack of the parent object?
Depending on the number of EditLevel, each single CancelEdit() operations can result in many very time consuming deserialization operations. Why not simply grab the first item on the undo stack (index 0) inside BLB and deserialize it, ignoring any higher stack entries?
You might not - but any binding you have may. If your collection is bound to any controls, I'm betting the .NET binding code would not react well to a "just go to the top" cancellation. Perhaps I'm wrong - but even if I am, how would you implement that kind of conditional logic in CancelEdit()? You can't change the method signature.
- Scott
Andreas:Sorry, maybe I missed something. But if I don't care about changes and any BeginEdit/ApplyEdit operation on any of the child objects made before? The parent object in my case a BLB and child objects are BB. I am wondering why the framework could not simply restore the first persisted state from the stack of the parent object?
Depending on the number of EditLevel, each single CancelEdit() operations can result in many very time consuming deserialization operations. Why not simply grab the first item on the undo stack (index 0) inside BLB and deserialize it, ignoring any higher stack entries?
Ah, well of course this would be possible. But you would need to code this yourself and the implementation would be sensitive to future changes in the internal implementation detail.
Another fairly efficient approach, though, would be instead to actually call ApplyEdit() in a loop until you reach EditLevel(1), and then call CancelEdit() to restore the first state pushed onto the undo stack. The ApplyEdit() calls would just pop the stack and discard the state without any deserialization.
This would avoid any deserialization of the higher stack entries and could still be implemented without much internal tinkering.
As the other poster noted, though, who knows how the user interface would react to this if the object was bound at the time.
Data binding is definetly something to consider. Thanks!
Copyright (c) Marimer LLC