Note that there are some explanatory texts on larger screens.

plurals
  1. POXML Serialization and Inherited Types
    primarykey
    data
    text
    <p>Following on from my <a href="https://stackoverflow.com/questions/19454/enforce-attribute-decoration-of-classesmethods">previous question</a> I have been working on getting my object model to serialize to XML. But I have now run into a problem (quelle surprise!).</p> <p>The problem I have is that I have a collection, which is of a abstract base class type, which is populated by the concrete derived types.</p> <p>I thought it would be fine to just add the XML attributes to all of the classes involved and everything would be peachy. Sadly, thats not the case!</p> <p>So I have done some digging on Google and I now understand <em>why</em> it's not working. In that <strong>the <code>XmlSerializer</code> is in fact doing some clever reflection in order to serialize objects to/from XML, and since its based on the abstract type, it cannot figure out what the hell it's talking to</strong>. Fine.</p> <p>I did come across <a href="http://www.codeproject.com/KB/XML/xmlserializerforunknown.aspx" rel="noreferrer">this page</a> on CodeProject, which looks like it may well help a lot (yet to read/consume fully), but I thought I would like to bring this problem to the StackOverflow table too, to see if you have any neat hacks/tricks in order to get this up and running in the quickest/lightest way possible.</p> <p>One thing I should also add is that I <strong>DO NOT</strong> want to go down the <code>XmlInclude</code> route. There is simply too much coupling with it, and this area of the system is under heavy development, so the it would be a real maintenance headache!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload