Here is my code to serialize an object to XML:
I know that I can apply the <XmlIgnore()> attribute to prevent XML serialization of the attribute but can code be done with this attribute?
Here is my situation:
I have many objects that I wish to serialize to XML. Each object has a Locked Boolean attribute and I am wanting to write some code such that if an object's Locked attribute is True, the whole object will not be serialized.
This is easy with a single object, just check the Locked attribute before object serialization, however, some objects have a List of another type of object. In this situation, can I prevent any of the List objects that are Locked to not be serialized?
Code:
Public Sub SerializeObjectToXML(FileName As String, ObjectToSerialize As Object, ObjectType As Type)
Dim Serializer As New XmlSerializer(ObjectType)
Dim Writer As New StreamWriter(FileName)
Serializer.Serialize(Writer, ObjectToSerialize)
Writer.Close()
End SubHere is my situation:
I have many objects that I wish to serialize to XML. Each object has a Locked Boolean attribute and I am wanting to write some code such that if an object's Locked attribute is True, the whole object will not be serialized.
This is easy with a single object, just check the Locked attribute before object serialization, however, some objects have a List of another type of object. In this situation, can I prevent any of the List objects that are Locked to not be serialized?