Case insensitive Deserialization

后端 未结 3 528
终归单人心
终归单人心 2021-01-17 11:03

I have an XML file where

We have defined classes to serialize or deserialize XML.

When we deserialize, if the XML contains like below where \"type<

3条回答
  •  一个人的身影
    2021-01-17 11:24

    Define the values of the DocumentType enumeration in the uppercase or use the standard adaptor property trick:

    [Description  ("The sharepoint's document type.")]
    [XmlIgnore]
    public DocumentType Type { get; set; }
    
    [Browsable    (false)]
    [XmlAttribute ("type")]
    public string TypeXml
    {
        get { return Type.ToString ().ToUpperInvariant () ; }
        set { Type = (DocumentType) Enum.Parse (typeof (DocumentType), value, true) ; }
    }
    

提交回复
热议问题