开发者

XmlDeserialization after renaming the classes involved

I have a bunch of xml serialized objects in a database.

But, I refactored and renamed the classes involved, so deserializing from the db is difficult.

I thought that by adding the term [XmlRoot("DB_Class_Name")] atop the renamed classes would fix the issue, but it doesn't appear to.

Is there a way to fix the issue using lab开发者_JS百科els like [XmlRoot], [XmlElement] etc., without renaming my classes to their old classnames, and without writing a special deserialize function?

Also, are there any good sources on what is happening under the hood when using xmldeserializaiton and labels like [XmlRoot]?


First of all, [XmlRoot] etc. aren't labels, they're attributes.

Second, [XmlRoot] only affects the class when that class is used as the root element of the document. It has no affect when an instance of that class is used as a child or other descendant.

Use [XmlType] on the class, or [XmlElement] on a property that is of the type of the class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜