[mapguide-commits] r4803 - in trunk/Tools/Maestro: Maestro
MaestroAPI MaestroAPI/Generated
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Apr 19 21:09:50 EDT 2010
Author: jng
Date: 2010-04-19 21:09:50 -0400 (Mon, 19 Apr 2010)
New Revision: 4803
Modified:
trunk/Tools/Maestro/Maestro/FormExpression.cs
trunk/Tools/Maestro/MaestroAPI/Generated/FdoProviderCapabilities-1.0.0.cs
trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs
Log:
Fix #1325: This submission includes the following changes:
- Change the FdoProviderCapabilities class to match the original xsd.exe output.
- Add a resource and version check to ServerConnectionBase such that if we're connecting to a MGOS server whose site version is < 2.2, it will pre-process the xml so that it matches the expected form before deserialization.
Modified: trunk/Tools/Maestro/Maestro/FormExpression.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/FormExpression.cs 2010-04-19 15:06:58 UTC (rev 4802)
+++ trunk/Tools/Maestro/Maestro/FormExpression.cs 2010-04-20 01:09:50 UTC (rev 4803)
@@ -130,7 +130,7 @@
//Functions
SortedList<string, FdoProviderCapabilitiesExpressionFunctionDefinition> sortedFuncs = new SortedList<string, FdoProviderCapabilitiesExpressionFunctionDefinition>();
- foreach (FdoProviderCapabilitiesExpressionFunctionDefinition func in caps.Expression.FunctionDefinitionCollection)
+ foreach (FdoProviderCapabilitiesExpressionFunctionDefinition func in caps.Expression.FunctionDefinitionList)
{
sortedFuncs.Add(func.Name, func);
}
@@ -144,7 +144,7 @@
btn.ToolTipText = func.Description;
string fmt = "{0}({1})";
List<string> args = new List<string>();
- foreach (FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition argDef in func.ArgumentDefinitionCollection)
+ foreach (FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition argDef in func.ArgumentDefinitionList)
{
args.Add(argDef.Name.Trim());
}
@@ -155,7 +155,7 @@
};
btnFunctions.DropDown.Items.Add(btn);
}
- LoadCompletableFunctions(caps.Expression.FunctionDefinitionCollection);
+ LoadCompletableFunctions(caps.Expression.FunctionDefinitionList);
//Spatial Operators
foreach (FdoProviderCapabilitiesFilterOperation op in caps.Filter.Spatial)
@@ -362,7 +362,7 @@
if (string.IsNullOrEmpty(_argStr))
{
List<string> tokens = new List<string>();
- foreach (FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition argDef in _func.ArgumentDefinitionCollection)
+ foreach (FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition argDef in _func.ArgumentDefinitionList)
{
tokens.Add("[" + argDef.Name.Trim() + "]");
}
Modified: trunk/Tools/Maestro/MaestroAPI/Generated/FdoProviderCapabilities-1.0.0.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/Generated/FdoProviderCapabilities-1.0.0.cs 2010-04-19 15:06:58 UTC (rev 4802)
+++ trunk/Tools/Maestro/MaestroAPI/Generated/FdoProviderCapabilities-1.0.0.cs 2010-04-20 01:09:50 UTC (rev 4803)
@@ -505,7 +505,7 @@
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("ArgumentDefinition", IsNullable=false)]
- public FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionCollection ArgumentDefinitionCollection {
+ public FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionCollection ArgumentDefinitionList {
get {
return this.m_argumentDefinitionList;
}
@@ -578,7 +578,7 @@
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("FunctionDefinition", IsNullable=false)]
- public FdoProviderCapabilitiesExpressionFunctionDefinitionCollection FunctionDefinitionCollection {
+ public FdoProviderCapabilitiesExpressionFunctionDefinitionCollection FunctionDefinitionList {
get {
return this.m_functionDefinitionList;
}
Modified: trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs 2010-04-19 15:06:58 UTC (rev 4802)
+++ trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs 2010-04-20 01:09:50 UTC (rev 4803)
@@ -20,6 +20,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Xml;
+using System.Text;
+using System.IO;
namespace OSGeo.MapGuide.MaestroAPI
{
@@ -227,6 +230,27 @@
/// <returns>The deserialized object</returns>
virtual public object DeserializeObject(Type type, System.IO.Stream data)
{
+ //HACK: MGOS 2.2 outputs different capabilities xml (because it's actually the correct one!), so
+ //without breaking support against 2.1 and older servers, we transform the xml to its pre-2.2 form
+ if (type == typeof(FdoProviderCapabilities) && this.SiteVersion < new Version(2, 2))
+ {
+ StringBuilder sb = null;
+ using (StreamReader reader = new StreamReader(data))
+ {
+ sb = new StringBuilder(reader.ReadToEnd());
+ }
+
+ //Pre-2.2 the elements were suffixed with Collection, change the suffix to List
+
+ sb.Replace("FunctionDefinitionCollection>", "FunctionDefinitionList>");
+ sb.Replace("ArgumentDefinitionCollection>", "ArgumentDefinitionList>");
+
+ byte[] bytes = Encoding.UTF8.GetBytes(sb.ToString());
+
+ //Replace the original input stream
+ data = new MemoryStream(bytes);
+ }
+
//Must copy stream, because we will be reading it twice :(
//Once for validation, and once for deserialization
System.IO.MemoryStream ms = new System.IO.MemoryStream();
More information about the mapguide-commits
mailing list