On Feb 23, 12:24 pm, "Martin Z" <martin.zar...@gmail.com> wrote:
> Hi,
>
> I'm trying to support a 3rd-party XML format for which there is no
> schema. As such, I've been making my objects that map to their format
> using the XMLSerializer... but there's one object that stops me.
>
> We have a class called Abstract-A, and a collection of Abstract-As
> we'll call A-List. One particular subtype of AbstractA is bothering
> me, because it works like this:
>
> <AList>
> <D foo="foo" bar="bar"/>
> <G foo="foo">quux</G>
> <B>
> <B-Child foo="foo"/>
> <B-Child foo="bar"/>
> </B>
> </AList>
>
> As you can see, the problem is B-child. I define AList as a list of
> Abstract-A's, and D, G, and B as subtypes of Abstract-A. But B is a
> list of B-Childs. I tried defining B's "XmlText" member as being a
> list of B-Childs, but you can only apply XmlText to strings (or arrays
> of strings).
>
> Any help would be appreciated.
I've tried a few things more so far, still with no success:
1) XmlText, mentioned above.
2) Multiple XMLElement members (one for each element in the array -
horrible klude idea) - didn't work.
3) Implementing IEnumerable - might've worked, but the XmlSerializer
no longer considers my type B to be a subtype of Abstract-A, so it
can't be used in the AList.
|