Undo Functionality

Undo Functionality

Old forum URL: forums.lhotka.net/forums/t/3115.aspx


scruffyduck posted on Thursday, June 28, 2007

Let me say up front that I am a beginner in the area of CSLA and I come to it via the Book Expert C# Business Objects.   I will also confess straight away that I am trying to use the n-level undo model in an application that I am writing.  So I hope you will not mind too much!
 
I have taken the UndoableBase Class and IUndoableObject interface and applied them to my particular situation.  I have, as it happens, modified it to allow redo as well as undo using two stacks instead of one.  This works as expected for the primary object.  However I am not getting what I epxect with fields in the primary object that are IUndoableObjects.    They are certainly being called and are pushing the serialized state onto thier stacks.  In fact one problem seems to be that they are pushing twice as when I look at things I have one undo object stacked in the primary object and two in the secondary.  However that is not my main concern.  The concern is that I can undo tha ctions on the primary object but those on the secondary do not seem to undo.  I have not modified the code for CopyState or UndoChanged and watching things in stepper mode shows that I am calling the subobjects CopyState as expected.
 
Apologies in advance if I am not explaining myself very well.  Reflection, for one thing is something I have not used before and I am a self taught amateur C# programmer.
 
Thanks for any help
 
Jon
 

RockfordLhotka replied on Friday, June 29, 2007

All I can say is good luck and test a lot. Getting undo to work across entire object graphs such that state remains consistent, eventing and data binding don't get messed up and so forth was quite difficult.

scruffyduck replied on Sunday, July 01, 2007

Hi Rocky
 
Thanks.  In the end I used the concepts behind your undo class and created my own.  Not quite as elegant since it uses the Memento pattern and saves state as another copy of the object.  It is 90% working now and although it is a bit messy at least it is my mess and I understand it (almost Smile [:)])
 
However I would not have getten this far without the classes you developed so thank you!
 
Jon

Copyright (c) Marimer LLC