防止VB.NET中的属性序列化 [英] Preventing serialization of properties in VB.NET
本文介绍了防止VB.NET中的属性序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个VB.NET类,正在通过XML在asmx文件中进行序列化.我已向要在序列化中忽略的数据成员添加了属性,但仍返回了该属性.我的类上还有<DataContract()>
属性,所有应该序列化的属性上都有DataMember
属性.我的财产声明是:
I have a VB.NET class which I'm serializing via XML in an asmx file. I've added attributes to the datamember I want to ignore in serialization, but it's still returned. I also have the <DataContract()>
attribute on my class and the DataMember
attribute on all properties which should be serialized. My property declaration is:
<ScriptIgnore()> _
<IgnoreDataMember()> _
Public Property Address() As SomeObject
推荐答案
通过向后备字段添加属性并从自动属性进行转换,我最终得到了停止序列化的属性:
By adding an attribute to the backing field and converting it from an auto-property, I eventually got the proprty to stop serializing:
<NonSerialized()> _
Private _address As SomeObject = Nothing
<ScriptIgnore()> _
<IgnoreDataMember()> _
<Xmlignore()>
Public Property address() As SomeObject
Get
Return _address
End Get
Set(ByVal value As SomeObject)
_address = value
End Set
End Property
这篇关于防止VB.NET中的属性序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文