GetObjectData & XMLSerializer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to serialise an object to obtain its serialiased XML representation. However I also want to control this by using the ISerializable interface, as I want to specifically override some values within the GetObjectData call.

We were using the XMLSerializer object to serialsie the object, but this doesnt' seem to run the GetObjectData call. It seems that only the BinaryFormatter object uses this method...(reading on the MSDN site, the XMLSerialiser and web Services only use shallow serialisation not deep

Using the BinaryFormatter object, I get the serialised object that I want, so....the question is, if I've got my serialised object in a memoryStream object, can I get at it in the XMLSerializer format?

ie..
Using

Dim bF As New BinaryFormatte
Dim ms As New MemoryStrea
bF.Serialize(ms, myObject

Can I return the same format xml as if I'd use

Dim xsSerializer As New Serialization.XmlSerializer(GetType(Base)
Dim swWriter As New System.IO.StringWrite
xsSerializer.Serialize(swWriter,
myObject

Thanks in advance

Craig
 
Nope - the XML serialization requires a lower level of trust, and only shows
the public view of a type. If you want this kind of behavior, you can either
use the SoapFormatter or write your own. The SoapFormatter creates a
full-fidelity representation of an object graph that's suitable for runtime
serialization purposes, but it's not in the same eye-friendly format as the
XML serializer provides.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com



Craig Hunter said:
I'm trying to serialise an object to obtain its serialiased XML
representation. However I also want to control this by using the
ISerializable interface, as I want to specifically override some values
within the GetObjectData call.
We were using the XMLSerializer object to serialsie the object, but this
doesnt' seem to run the GetObjectData call. It seems that only the
BinaryFormatter object uses this method...(reading on the MSDN site, the
XMLSerialiser and web Services only use shallow serialisation not deep)
Using the BinaryFormatter object, I get the serialised object that I want,
so....the question is, if I've got my serialised object in a memoryStream
object, can I get at it in the XMLSerializer format??
 
Back
Top