Inherit from Document

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by byperman - Sint-Niklaas, Belgium
Avatar
Hi,

I've got a class (Script) that inherits from Document, that adds some functionality and holds a few extra properties (version, modification, things like that). I used to hold all of this in a separate class, and kept Document and Script synchronized; this, however, was slow and hard to maintain.

Now that I inherit from Document, I am no longer able to serialize my properties because XmlSerializer tries to serialize all kinds of properties from Document. Unfortunately there seems to be no way to prevent the XmlSerializer from doing this, except putting the XmlIgnoreAttribute before every property in the base class, and then control the serialization by overriding the properties you'd like to see serialized.

Any thoughts on this issue?

Thanks a lot,
Brecht

Comments (6)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I think what you said is correct... you have to apply those attributes to use default XML serialization mechanisms. Maybe you should manually write to an XML file using an XmlWriter instead. Then you can control what gets written.


Actipro Software Support

Posted 19 years ago by byperman - Sint-Niklaas, Belgium
Avatar
And would you consider applying XmlIgnoreAttribute to every property in ActiproSoftware.SyntaxEditor.Document?
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Probably not because some other people may not want it there in case they want to serialize some of those properties. I'd rather leave it the default.


Actipro Software Support

Posted 19 years ago by byperman - Sint-Niklaas, Belgium
Avatar
Please correct me if I'm wrong, but I believe trying to serialize Document results in errors nowadays, so why not setting properties to XmlIgnore? Should anyone want to serialize them, they can wrap them in their own properties, no?

[Modified at 06/14/2005 10:00 AM]
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I think it's just best if you determine which properties you want to save yourself and serialize those. Or better yet, make your own class that contains all your properties to serialize, and add it as a property in your SyntaxEditor-based class. Then just serialize your custom property class.


Actipro Software Support

Posted 19 years ago by byperman - Sint-Niklaas, Belgium
Avatar
I started doing that, guessing that was the only option. Thanks.
The latest build of this product (v24.1.0) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.