views:

103

answers:

0

I have an XML document that looks like this:

<MyEntity>
    <Vehicles>
        <Car />
        <Truck />
    </Vehicles>
</MyEntity>

I want to deserialise it into the following structure:

public class MyEntity
{
    public Vehicle[] Vehicles { get; set; }
}

public class Vehicle {}
public class Car : Vehicle {}
public class Truck : Vehicle {}

Is it possible to do this without having to decorate the MyEntity.Vehicles property with an XmlArrayItem attribute for each possible vehicle type? I may get new types of Vehicles that I don't know about at compile time, but are discoverable at run time.