[From China] How to use "List object" alone and "N-level Undo"?

[From China] How to use "List object" alone and "N-level Undo"?

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


harveyhu posted on Saturday, November 26, 2011

Sorry, I do not understand English. Translated from GOOGLE
----------------------------------------------------------
Userd alone "List object".

When I Call method :: BeginEdit()

exception message like this :"Edit level mismatch in CopyState".

why? can you help me?


How to use "List object" alone and "N-level Undo"?


----------------------------------------------------------


Chinese-->

不好意思,我不懂英文,所以用Google翻译来表达意思

当我单独使用List对象时,我想使用它的N层撤销机制,但当我直接使用List.BeginEdit()时出现下面异常.

"Edit level mismatch in CopyState",调试CSLA代码时发现如下:

 protected internal void CopyState(int parentEditLevel)
 {
    ...

    if (this.EditLevel + 1 > parentEditLevel)
    {
       throw new UndoException(string.Format(Resources.EditLevelMismatchException, "CopyState"));
    }
   ...
 }

请问如何单独使用List对象,并且能够启用N层撤销机制?

JonnyBee replied on Sunday, November 27, 2011

You should only call BeginEdit/ApplyEdit/CancelEdit on objects that are not active in databinding.

When you get that error message it is likely that BeginEdit has already been called on one or more of the child/grandchild objects.

When you call BeginEdit a snapshot of your object structure is pushed to the stack and if any child/grandchild object has en Editlevel that is NOT a match to the parent level you will get this error.

The solution: You must call BeginEdit before you call BeginEdit on any child objec or connect the object to the UI by using DataBinding. 

 

 

Copyright (c) Marimer LLC