svcutil, XmlSerializer and xsd:list
Posted
by Dmitry Ornatsky
on Stack Overflow
See other posts from Stack Overflow
or by Dmitry Ornatsky
Published on 2010-04-19T11:05:57Z
Indexed on
2010/04/19
12:23 UTC
Read the original article
Hit count: 389
I'm using svcutil to generate classes from service metadata. This XML schema
<xsd:complexType name="FindRequest">
...
<xsd:attribute name="Significance" type="Significance" use="optional" />
</xsd:complexType>
<xsd:simpleType name="Significance">
<xsd:list>
<xsd:simpleType>
<xsd:restriction base="xsd:int">
<xsd:enumeration value="1" />
<xsd:enumeration value="2" />
<xsd:enumeration value="3" />
</xsd:restriction>
</xsd:simpleType>
</xsd:list>
produces following code:
public partial class FindRequest
{
...
private int significanceField;
private bool significanceFieldSpecified;
[System.Xml.Serialization.XmlAttributeAttribute()]
public int Significance
{
get
{
return this.significanceField;
}
set
{
this.significanceField = value;
}
}
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool SignificanceSpecified
{
get
{
return this.significanceFieldSpecified;
}
set
{
this.significanceFieldSpecified = value;
}
}
}
My questions are:
Is it possible to make XmlSerializer understand this type of list:
<FindRequest Significance="1 2 3"/>
For example by using some kind of a flags-style enum:
public enum EmployeeStatus { [XmlEnum(Name = "1")] One = 1, [XmlEnum(Name = "2")] Two = 2, [XmlEnum(Name = "3")] Three = 4 }
If the answer is yes, Is it possible to make svcutil/xsd.exe generate classes that are serialized that way without changing the schema?
© Stack Overflow or respective owner