3

I'm trying to write a program that should serialize a class to an XML file, but recently my specification changed and now I have a previously unique and not null field changed like this:

  • Normal case, like before, fields are not changed [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 kind of 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
Bugs
  • 4,491
  • 9
  • 32
  • 41
Forna
  • 149
  • 3
  • 13
  • Because your serialization based on the "business" logic you can use two different types for different cases – Fabio Mar 21 '17 at 10:42

0 Answers0