I got this XML to deserialize:
<Rules>
<Rule>
<Id>1</Id>
<Name>Uso do SET NOCOUNT ON</Name>
<TypesAffected>
<TypeAffected>Procedure</TypeAffected>
<TypeAffected>Trigger</TypeAffected>
<TypeAffected>Function</TypeAffected>
</TypesAffected>
<Items>
<Item>SET NOCOUNT</Item>
</Items>
<Mode>ON</Mode>
<Action>Find</Action>
<Where>Body</Where>
<Type>Required</Type>
<Message>NOCOUNT ON não foi localizado na procedure, favor ajustar.</Message>
</Rule>
</Rules>
and These enums:
[Serializable()]
public enum Action
{
[XmlEnum(Name = "Find")]
Find,
[XmlEnum(Name = "NotFind")]
NotFind
}
[Serializable()]
public enum Where
{
[XmlEnum(Name = "Name")]
Name,
[XmlEnum(Name = "Body")]
Body
}
[Serializable()]
public enum Type
{
[XmlEnum(Name = "Required")]
Required
}
And this is the class of the whole xml:
[Serializable()]
[XmlRoot("Rule")]
public class Rule
{
public int Id { get; set; }
public string Name { get; set; }
[XmlArrayItem("TypeAffected", typeof(string))]
public List<string> TypesAffected { get; set; }
[XmlArrayItem("Item", typeof(string))]
public List<string> Items { get; set; }
public string Mode { get; set; }
[XmlElement("Action")]
public Action Action { get; set; }
[XmlElement("Where")]
public Where Where { get; set; }
[XmlElement("Type")]
public Type Type { get; set; }
public string Message { get; set; }
}
When i deserialize the xml it is returning the first value of the enum it doesn't get the REAL value of the xml, the other values is returning all fine.
No comments:
Post a Comment