WriteXML for custom properties

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 04-Mar-2005 22:30:30   

Greetings,

I am utilizing an entity's WriteXML / ReadXML to be able to implement a cancelEdit feature where if canceled Edit on an enitity, all its fields (including EntityCollectiob) fields are preserved (pitty that SaveFields does NOT implement this)

All is working ok except that my derived entities have some extar properties (BrokenRulee, ParentObject) and so does each entity in each of the related collections. The WriteXML does NOT serialize the reference to these extra properties and I get the entity after ReadXML with these properties being as nothig. I want to write my own logic to APPEND to the XML document a node that would preserve these properties. I have read the XML helper bu I don't know how to go about customizing the XML document in that manner. What I want to be able to do is as follows:

Dim cloneXML as String = "" entity.WriteXML(cloneXML)

' custom code to customize the XML content of cloneXML

writer.write(cloneXML)

confused

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 06-Mar-2005 11:39:48   

omar wrote:

Greetings,

I am utilizing an entity's WriteXML / ReadXML to be able to implement a cancelEdit feature where if canceled Edit on an enitity, all its fields (including EntityCollectiob) fields are preserved (pitty that SaveFields does NOT implement this)

That's very problematic. I've thought of implementing that, but it turns out you have to version graphs of objects in that case (as order.Customer points to the customer which holds order in its Orders collection, so version Customer.Orders, also versions order... )

You should use the serialization code to a memstream though to preserve clones for cancel. This is much faster. Use a binaryformatter and a memstream. Serialize the object (entity or collection) to the memstream. Go into your form. User clicks cancel, you grab the memstream object, seek back to the start and deserialize from it. Everything's back simple_smile

All is working ok except that my derived entities have some extar properties (BrokenRulee, ParentObject) and so does each entity in each of the related collections. The WriteXML does NOT serialize the reference to these extra properties and I get the entity after ReadXML with these properties being as nothig.

It serializes extra properties to the xml if they're simple types, and I think your properties hold complex types, which indeed don't work. The idea is that when you re-instantiate an entity, these rules are created when the entity is created. With the memstream trick you don't have this problem

I want to write my own logic to APPEND to the XML document a node that would preserve these properties. I have read the XML helper bu I don't know how to go about customizing the XML document in that manner. What I want to be able to do is as follows:

Dim cloneXML as String = "" entity.WriteXML(cloneXML)

' custom code to customize the XML content of cloneXML

writer.write(cloneXML) confused

Appending xml is not that easy in this case, as you want to append it recursively, I'd suggest you to use the memstream trick.

Frans Bouma | Lead developer LLBLGen Pro