[mapguide-commits] r6049 - in trunk/Tools/Maestro: Maestro.Editors/Generic OSGeo.MapGuide.MaestroAPI

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Aug 9 07:02:53 EDT 2011


Author: jng
Date: 2011-08-09 04:02:53 -0700 (Tue, 09 Aug 2011)
New Revision: 6049

Modified:
   trunk/Tools/Maestro/Maestro.Editors/Generic/XmlEditorCtrl.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
Log:
#1774: Fix serialization calls to use ResourceTypeRegistry as that contains serialization hooks to strip out unnecessary attributes of document root elements that exist as child elements of other documents


Modified: trunk/Tools/Maestro/Maestro.Editors/Generic/XmlEditorCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Generic/XmlEditorCtrl.cs	2011-08-09 06:21:33 UTC (rev 6048)
+++ trunk/Tools/Maestro/Maestro.Editors/Generic/XmlEditorCtrl.cs	2011-08-09 11:02:53 UTC (rev 6049)
@@ -30,6 +30,7 @@
 using OSGeo.MapGuide.ObjectModels;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using OSGeo.MapGuide.MaestroAPI.Exceptions;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace Maestro.Editors.Generic
 {
@@ -359,7 +360,7 @@
         public override void Bind(IEditorService service)
         {
             var res = service.GetEditedResource();
-            this.XmlContent = res.Serialize();
+            this.XmlContent = ResourceTypeRegistry.SerializeAsString(res);
             InitResourceData(service);
         }
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs	2011-08-09 06:21:33 UTC (rev 6048)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs	2011-08-09 11:02:53 UTC (rev 6049)
@@ -1222,7 +1222,7 @@
         /// <param name="resourceid">The resourceid.</param>
         public void SaveResourceAs(OSGeo.MapGuide.MaestroAPI.Resource.IResource resource, string resourceid)
         {
-            var stream = resource.SerializeToStream();
+            var stream = ResourceTypeRegistry.Serialize(resource);
             SetResourceXmlData(resourceid, stream);
         }
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs	2011-08-09 06:21:33 UTC (rev 6048)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs	2011-08-09 11:02:53 UTC (rev 6049)
@@ -265,6 +265,22 @@
         }
 
         /// <summary>
+        /// Serializes the specified resource.
+        /// </summary>
+        /// <param name="res"></param>
+        /// <returns></returns>
+        public static string SerializeAsString(IResource res)
+        {
+            using (var stream = Serialize(res))
+            {
+                using (var sr = new StreamReader(stream))
+                {
+                    return sr.ReadToEnd();
+                }
+            }
+        }
+
+        /// <summary>
         /// Deserializes the specified XML.
         /// </summary>
         /// <param name="xml">The XML.</param>



More information about the mapguide-commits mailing list