How to use custom-derived XmlWriter with IXmlSerializable?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a custom-derived XmlWriter that I can pass into WriteXml(XmlWriter writer) methods that Im using on objects with IXmlSerializable and the XmlSerializer. In order to do this, my custom writer gets implicitly converted from its custom-derived
type by upcast to the base XmlWriter on entry into the WriteXml method, and then I have to explicitly convert by downcast back to my custom-derived type.
What is the performance penalty for all these upcasts and downcasts? And is there any way possible to do this more efficiently? Is it possible to derive from XmlSerializer class and IXmlSerializable interface in an expedient manner? Or
would it be necessary to re-code an entirely new serializer from basics? And obviously I do not want to do the latter....

View the full article
 
Back
Top