maldworth / aldsoft.acord

.NET Helper Library for Serializing and Deserializing ACORD LA XML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Life_Type as child of Policy_Type

tpluscode opened this issue · comments

I wanted to add <Life> node under TXLifeRequest/OLifE/Holding/Policy and I noticed that the Policy_Type doesn't have a Life property. Upon inspecting the type I found the annotations on Item1 property

[XmlElement("Annuity", typeof (Annuity_Type))]
    [XmlElement("DisabilityHealth", typeof (DisabilityHealth_Type))]
    [XmlElement("Life", typeof (Life_Type))]
    [XmlElement("PropertyandCasualty", typeof (PropertyandCasualty_Type))]
    public object Item1
    {
      get; 
      set;
    }

Why isn't there a property for DisabilityHealth, Life and PropertyandCasualty?

This is how xsd.exe generates classes from schemas that have schema ChoiceElements. In order for it to perform the validation (i.e. ensure that only one of those 4 possible elements is present), it has to leave it as an open ended object. There will also be spots with object[] Items and ItemsChoiceType1[] ItemsElementName, where it can have a collection of ChoiceElements. The order matters in these scenarios of the elements in both arrays.

For Example, if you are trying to assign an Annuity, and a DisabilityHealth to the to /TXLifeRequest/OLifE/Holding/Policy element, then that is not following the schema.

If you want Life_Type in Item, just assign it to the object and it will work. Doesn't create the best Intellisense experience for the developer, but ensures a valid xml schema!