Obsolete attribute causes property to be ignored by XmlSerialization

前端 未结 6 1089
臣服心动
臣服心动 2020-12-05 12:54

I\'m refactoring some objects that are serialized to XML but need to keep a few properties for backwards compatibility, I\'ve got a method that converts the old object into

6条回答
  •  生来不讨喜
    2020-12-05 13:23

    You may try the following workaround:

    add a method named

    ShouldSerializeOldObject ()
    {
       return true;
    }
    
    ShouldSerializeAnotherOldObject ()
    {
       return true
    }
    

    this may override the obsolete Attribute

提交回复
热议问题