[mapguide-commits] r6252 - in
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI: . ObjectModels
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Nov 28 06:56:41 EST 2011
Author: jng
Date: 2011-11-28 03:56:41 -0800 (Mon, 28 Nov 2011)
New Revision: 6252
Modified:
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/UntypedResource.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/XmlValidator.cs
Log:
Fix ResourceTypeRegistry to support serialization/deserialization of unrecognised schema versions (object form is UntypedResource in such cases). Also abort XML schema validation if one or more XML schemas could not be found
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/UntypedResource.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/UntypedResource.cs 2011-11-26 12:34:54 UTC (rev 6251)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/UntypedResource.cs 2011-11-28 11:56:41 UTC (rev 6252)
@@ -40,6 +40,13 @@
this.ResourceVersion = new Version(version);
}
+ internal UntypedResource(string xml, ResourceTypes resourceType, Version version)
+ {
+ this.XmlContent = xml;
+ this.ResourceType = resourceType;
+ this.ResourceVersion = version;
+ }
+
/// <summary>
/// Gets or sets the current connection.
/// </summary>
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs 2011-11-26 12:34:54 UTC (rev 6251)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs 2011-11-28 11:56:41 UTC (rev 6252)
@@ -259,7 +259,12 @@
{
var rd = res.GetResourceTypeDescriptor();
if (!_serializers.ContainsKey(rd))
- throw new SerializationException(Properties.Resources.ERR_NO_SERIALIZER + rd.ToString());
+ {
+ var utr = res as UntypedResource;
+ if (utr == null)
+ throw new SerializationException(Properties.Resources.ERR_NO_SERIALIZER + rd.ToString());
+ return utr.SerializeToStream();
+ }
return _serializers[rd].Serialize(res);
}
@@ -293,7 +298,11 @@
throw new SerializationException(Properties.Resources.ERR_NOT_RESOURCE_CONTENT_XML);
if (!_serializers.ContainsKey(rd))
- throw new SerializationException(Properties.Resources.ERR_NO_SERIALIZER + rd.ToString());
+ {
+ var rtype = (ResourceTypes)Enum.Parse(typeof(ResourceTypes), rd.ResourceType);
+ return new UntypedResource(xml, rtype, rd.Version);
+ //throw new SerializationException(Properties.Resources.ERR_NO_SERIALIZER + rd.ToString());
+ }
return _serializers[rd].Deserialize(xml);
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/XmlValidator.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/XmlValidator.cs 2011-11-26 12:34:54 UTC (rev 6251)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/XmlValidator.cs 2011-11-28 11:56:41 UTC (rev 6252)
@@ -163,6 +163,8 @@
var xsd = GetXsd(xsdPath, res.ValidatingSchema);
if (xsd != null)
xsds.Add(res.ValidatingSchema, xsd);
+ else
+ return; //One or more schemas is not found. Cannot proceed. Let MG figure it out
//HACK: Yes this is hard-coded because XmlSchema's dependency resolution sucks!
More information about the mapguide-commits
mailing list