XmlSerializer 属性反序列化顺序
只是想知道是否有人知道 XmlSerializer 如何确定反序列化任何给定对象属性的顺序。
添加信息:
我有一个这样的类:
private bool _hasGaps = false;
public bool HasGaps
{
get { return _hasGaps; }
set
{
_hasGaps = value;
}
}
private List<GapInfo> _gaps;
public List<GapInfo> Gaps
{
get { return _gaps; }
set
{
_gaps = value;
}
}
我在 Gaps setter 和 HasGaps setter 中设置了一个断点,Gaps 首先被反序列化。
更多信息
XML 如下所示:
<Tube Id="3df08765-c4e7-4a87-a0ed-ec76169b47af" Name="Tube">
<HasGaps>false</HasGaps>
<Gaps />
</Tube>
Just wondering if anyone knows how the XmlSerializer determines the order for deserializing any given object's properties.
Added info:
I have a class like this:
private bool _hasGaps = false;
public bool HasGaps
{
get { return _hasGaps; }
set
{
_hasGaps = value;
}
}
private List<GapInfo> _gaps;
public List<GapInfo> Gaps
{
get { return _gaps; }
set
{
_gaps = value;
}
}
I set a breakpoint in both Gaps setter and HasGaps setter, Gaps gets deserialized first.
More info
Here's what the XML looks like:
<Tube Id="3df08765-c4e7-4a87-a0ed-ec76169b47af" Name="Tube">
<HasGaps>false</HasGaps>
<Gaps />
</Tube>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它按照它们在类中出现的顺序对它们进行反序列化。
您是否有理由相信它可能使用不同的顺序?
It deserializes them in the order they appear in the class.
Did you have reason to believe it might use a different order?