[mapguide-users] MgByteReader and XmlSerializer question

Kenneth, GEOGRAF A/S ks at geograf.dk
Mon Oct 8 09:16:01 EDT 2007


Yes, you are missing a few key pieces of information.

First of all, the MapGuideAPI (MgMapCollection and others) are based on 
C++ classes and actually wrappers created with a system called SWIG.
This means that not all properties are public and writeable, thus you 
cannot use the .Net serializers.

Second, the streams in MapGuide are also wrapped, and thus do not share 
a common stream base class, and cannot be used as such.

The ToString function does NOT return the stream content as a string, 
but rather "OSGeo.MgByteReader".

I also use the .Net environment, and agree that it should be doable the 
way you describe, but it would be very hard to build an maintain a 
similar functionality for all the supported languages (php, .Net and Java).

I have build seperate class instances, from the Xsd files. These classes 
can then be serialized/deserialized like you would expect.

Regards, Kenneth, GEOGRAF A/S



Maksim Sestic skrev:
> Is it possible to use System.Xml.Serialization.XmlSerializer class to
> instantiate actual type returned as XML by MgByteReader.ToString function? I
> see people are using DOM to iterate through resulting XML and I simply can't
> get why, since there are specific OSGeo.MapGuide type definitions.
> Deserialization should go like:
>
> (prepare m_MemoryStream out of MgResourceService.EnumerateResources...)
>
> Dim m_Maps As MgMapCollection
> Dim m_XmlSerializer As XmlSerializer = New
> XmlSerializer(GetType(MgMapCollection))
> m_Maps = CType(m_XmlSerializer.Deserialize(m_MemoryStream), MgMapCollection)
> For Each m_Map As MgMap In m_Maps
>    Console.WriteLine(m_Map.Name)
> Next
>
> Or am I missing something?
>
> Regards,
> Maksim Sestic
>   


More information about the mapguide-users mailing list