0

WSCF blue generates something like this from choice in xml-schema:

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34234")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.some.com/nis/componentsync/v1.0", TypeName="tComponentKey")]
[System.Xml.Serialization.XmlRootAttribute(ElementName="tComponentKey")]
public partial class TComponentKey
{

    private object itemField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("id", typeof(int))]
    [System.Xml.Serialization.XmlElementAttribute("label", typeof(string))]
    public object Item
    {
        get { return this.itemField; }
        set { this.itemField = value; }
    }
}

EDIT: The 2 lines below is sorted out. If you add one more choice in schema with type string or int it can't separate them anymore only by type.

In some cases it generates also ItemElementName or something that is enum so I know if it was id or label. For some reason for this choice it didn't, so I wonder if this can be set/get somehow.

EDIT: The 2 lines above is sorted out. See explanation above

In degbugger I can see for the object that what the attribute is. It can show label=ABC123 when I assign string ABC123 for property. So it's based on type. However label can be also int and I would like to set, get it myself and not trust this type based non-sense.

EDIT: Examples of xml in request-messages that are deserialized to object:

Here consumer wants to fetch the component by it's integer id.

<v1:componentkey>
        <!--You have a CHOICE of the next 2 items at this level-->
        <v11:id>123123</v11:id>
</v1:componentkey>

Here consumer wants to fetch the component by it's string label.

<v1:componentkey>
        <!--You have a CHOICE of the next 2 items at this level-->
        <v11:label>ABC123</v11:label>
</v1:componentkey>
char m
  • 7,840
  • 14
  • 68
  • 117
  • What kind of data are you storing that can be both an int and a string? – user2920518 Dec 04 '14 at 12:45
  • @user2920518 what u mean? normal xsd:choice-elelement. it can be also complextype. i can put example if u not familiar w xml schemas. – char m Dec 06 '14 at 11:49

0 Answers0