I have read several dozen articles on the xs:Choice XSD element but cant wrap my head around how we are supposed to use the resulting class. Here is the XSD element and the class conversion from Xsd2Code++:
<xs:element name="VariantRoads">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="Variant" minOccurs="0"/>
<xs:element ref="DepVariant"/>
<xs:element ref="ArrVariant"/>
</xs:choice>
</xs:complexType>
</xs:element>
[XmlArrayItemAttribute("ArrVariant", typeof(ArrVariantType), IsNullable = false)]
[XmlArrayItemAttribute("DepVariant", typeof(DepVariantType), IsNullable = false)]
[XmlArrayItemAttribute("Variant", typeof(VariantType), IsNullable = false)]
public object[] VariantRoads
{
get
{
return _variantRoads;
}
set
{
_variantRoads = value;
}
}
So that compiles and now I am ready to start populating my main class.
BaseRoadType brd = new BaseRoadType();
brd.VariantRoads = = new object[3]; // not sure how to initialize
brd.VariantRoads[0] = ??? // how do I assign my property
I am just really lost on how I should populate the VariantRoads class and then read it later and determine what choice was made.