about undoablebase class

about undoablebase class

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


zlonly posted on Friday, December 08, 2006

Hi,everyone

    I am working through CSLA,In CopyState() function of Csla.Core.UndoableBase class,why set currentType to currentType.BaseType.

   thks

 

 

ajj3085 replied on Friday, December 08, 2006

If I remember correct, the undo code only works on the current type, not any subclasses.  The reason is that the superclass could have a private property named XYZ, and the subclass may also have a private property named XYZ.  So basically the code just worries about the properties at the subclass, then it processes superclass properties, and so on (if there's more in the inheritince chain).

zlonly replied on Sunday, December 10, 2006

thanks,that's right.I see.

zlonly replied on Friday, January 26, 2007

sorry,I look carefully in code found in page 131 of book,CopyState function set currentType to currentType.basetype.I can't understand,please.

I come from China,my English is limited,sorry

zlonly replied on Sunday, January 28, 2007

Nobody see my problem?Take one example,if invoice class inherited from businessbase class,when we invoke BeginEdit function of invoice class,the function will get snapshot of itself and all base class up to undoablebase.Is this right?Why invoice should get snapshot of it's base class?

RockfordLhotka replied on Sunday, January 28, 2007

The process must get a snapshot of the base class. The base class may have fields that must be restored when CancelEdit() is called.

For example, BusinessBase contains fields like IsNew, IsDeleted and others, that must be restored to their original values when CancelEdit() is called.

zlonly replied on Monday, January 29, 2007

Thanks Rocky.After understanding why to get snapshot of baseclass,I faced with another question.Do all business object such as invoice,project will get the same snapshot of Csla.Core.BusinessBase upto Csla.Core.UndoableBase in the process of n-level undoing operation?

RockfordLhotka replied on Monday, January 29, 2007

I suggest you review Chapter 3 carefully. That chapter walks through the implementation of the n-level undo functionality in some detail.
 
Each instance of a business object is responsible for its own state - from top to bottom of the inheritance hierarchy. That is required to avoid breaking encapsulation.
 
Rocky
 

zlonly replied on Tuesday, January 30, 2007

Ok,I'll review the chapter.

thks

Copyright (c) Marimer LLC