How to actualize the N-Level UndoHow to actualize the N-Level Undo
Old forum URL: forums.lhotka.net/forums/t/5271.aspx
future_zheng posted on Wednesday, August 20, 2008
- Use Version Decription: I'm using Csla.net 3.0.4.0 and using ProjectTracker.Library。
- Querstion:NOW has a requirement,When set value of project's member, I will Copy a state;the coding under: public string Name{ get {CanReadProperty("Name",true); return _name; }
set { CanWriteProperty("Name",true);if (value == null) value = string.Empty; if (_name != value)
{_name = value; BeginEdit(); PropertyHasChanged();
}} } 。I deal like this coding for all properies. I want to record very time change,than i want to call CancelEdit() for every change. throw a Exception"Edit level mismatch in UndoChanges" .
- Please tell me how to actualize every undo?
- label:I don't more modify the ProjectTracker.Library and UI Demo;when I fetch Data……
ajj3085 replied on Wednesday, August 20, 2008
Take the BeginEdit out. It's not needed, and as you can see causes problem.
If you want form level undo, I think you'll need to call BeginEdit on your BO, but BEFORE you do the databinding. To CancelEdit, you'll have to unbind the BO before you call the Cancel (or End).
Once databound, databinding handles calling Begin / Cancel and End edit for the user. You don't need to do any work there, it's done automatically unless you disabled support for databinding undo.
future_zheng replied on Wednesday, August 20, 2008
Thanks for you suggest.Please allow to explain my think.I want to actualize like word .After I input three times,if I call undo function for three times,I will return to initiation location.RockfordLhotka replied on Wednesday, August 20, 2008
The undo feature of CSLA .NET doesn't work like that in Word.
Word uses a command-based undo structure, where they undo changes command-by-command.
CSLA uses a snapshot-based undo structure, where a snapshot of the object is taken, and then an undo goes back to that snapshot.
future_zheng replied on Thursday, August 21, 2008
Thanks for Rocky's reply
Copyright (c) Marimer LLC