How can I ignore certain fields conditionally on XML serialization
I'm trying to write a program that should serialize a class to an XML file, but recently my spec has changed and now I have a previously unique and not null field like this:
- The usual case, as before, the fields do not change [a, b, c]
- n fields with a link to another field id [a, b, c, id]
How can I change my class to allow this behavior?
Actual:
<Serializable>
Public Class DataType
Public FieldToChange As New FieldType 'FieldType to change
End Class
<Serializable>
Public class FieldType
Public a As Integer
Public b As Integer
Public c As Integer
End Class
Future:
<Serializable>
Public Class ClassWithElemToChangeType
<XmlElement("FieldType")> ' Is it right?
Public FieldToChange As New List(Of FieldType)
End Class
<Serializable>
Public class FieldType
Public a As Integer
Public b As Integer
Public c As Integer
Public id As Integer
' How can i add a field that gets ignored whenever is null
' or how can I programmatically tell my serializer to ignore
End Class
+3
source to share
No one has answered this question yet
See similar questions:
or similar: