Note that there are some explanatory texts on larger screens.

plurals
  1. POXML Deserialization of Inherited Objects
    primarykey
    data
    text
    <p>I have an object <code>InputFile</code> that has arrays and objects to hold the contents of a file. I also have <code>ABCFile</code> and <code>XYZFile</code> that are both inherited from <code>InputFile</code> that will read different types of file and store them into the projected members of <code>InputFile</code>.</p> <p>Since the serialization and deserialization of both of these objects are identical to the parent object, I have implemented a standard XML serialization interface on the parent object. During deserialization a few paramters are read, a <code>Read</code> function is called (to load a file), then the deserialization finishes.</p> <p>The serialization works great, but the deserialization (of <code>List&lt;InputFile&gt;</code>) doesn't work because the deserializer calls the parents stub <code>Read</code> file function instead of <code>ABCFile</code> or <code>XYZFile</code>'s.</p> <p>How can I get the deserialization to recognize the correct type of object to use? It is possible that my <code>List&lt;InputFile&gt;</code> will have a mix of file types.</p> <p>Thanks</p> <p>The code I use to serialize the object:</p> <pre><code>public class InputFileHolder : IXmlSerializable { ... public void WriteXml(XmlWriter w) { XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); XmlSerializer ifXml = new XmlSerializer(typeof(List&lt;InputFile&gt;)); ifXml.Serialize(w, InputFiles, ns); //More serialization } </code></pre> <p>Any ideas how to maintain the object type when I custom serialize the List?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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