[mapguide-commits] r5004 - in sandbox/maestro-3.0: MaestroAPITests
OSGeo.MapGuide.MaestroAPI/ObjectModels
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jul 7 21:36:03 EDT 2010
Author: jng
Date: 2010-07-08 01:36:03 +0000 (Thu, 08 Jul 2010)
New Revision: 5004
Modified:
sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs
Log:
Add some new APIs to FeatureSourceType:
- UsesAliasedDataFiles : Indicates whether this feature source connects to externally aliased files
- UsesEmbeddedDataFiles : Indicates whether this feature source connects to an embedded file
- Also add some null guards around the ConnectionString property.
Modified: sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs
===================================================================
--- sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs 2010-07-07 22:32:01 UTC (rev 5003)
+++ sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs 2010-07-08 01:36:03 UTC (rev 5004)
@@ -599,5 +599,32 @@
//There's no 1.1.0 -> 1.2.0 upgrader registered. This should fail.
var obj = conv.Upgrade(orig, new Version(1, 3, 0));
}
+
+ [Test]
+ public void TestFeatureSource()
+ {
+ var fs = new FeatureSourceType();
+ Assert.IsTrue(fs.ConnectionString.Length == 0);
+
+ fs.Provider = "OSGeo.SDF";
+ fs.ConnectionString = "File=%MG_DATA_FILE_PATH%Foo.sdf";
+
+ Assert.IsTrue(fs.UsesEmbeddedDataFiles);
+ Assert.IsFalse(fs.UsesAliasedDataFiles);
+
+ fs = new FeatureSourceType();
+ fs.Provider = "OSGeo.SHP";
+ fs.ConnectionString = "DefaultFileLocation=%MG_DATA_PATH_ALIAS[foobar]%";
+
+ Assert.IsTrue(fs.UsesAliasedDataFiles);
+ Assert.IsFalse(fs.UsesEmbeddedDataFiles);
+
+ fs = new FeatureSourceType();
+ fs.Provider = "OSGeo.SQLServerSpatial";
+ fs.ConnectionString = "Service=(local)\\SQLEXPRESS;DataStore=TEST";
+
+ Assert.IsFalse(fs.UsesEmbeddedDataFiles);
+ Assert.IsFalse(fs.UsesAliasedDataFiles);
+ }
}
}
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs 2010-07-07 22:32:01 UTC (rev 5003)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs 2010-07-08 01:36:03 UTC (rev 5004)
@@ -137,9 +137,12 @@
get
{
List<string> values = new List<string>();
- foreach (var p in this.Parameter)
+ if (this.Parameter != null)
{
- values.Add(p.Name + "=" + p.Value);
+ foreach (var p in this.Parameter)
+ {
+ values.Add(p.Name + "=" + p.Value);
+ }
}
return string.Join(";", values.ToArray());
}
@@ -148,6 +151,9 @@
if (value == null)
throw new ArgumentNullException("value");
+ if (this.Parameter == null)
+ this.Parameter = new System.ComponentModel.BindingList<NameValuePairType>();
+
this.Parameter.Clear();
string[] tokens = value.Split(';');
foreach (var tok in tokens)
@@ -160,5 +166,23 @@
}
}
}
+
+ [XmlIgnore]
+ public bool UsesEmbeddedDataFiles
+ {
+ get
+ {
+ return this.ConnectionString.Contains("%MG_DATA_FILE_PATH%");
+ }
+ }
+
+ [XmlIgnore]
+ public bool UsesAliasedDataFiles
+ {
+ get
+ {
+ return this.ConnectionString.Contains("%MG_DATA_PATH_ALIAS[");
+ }
+ }
}
}
More information about the mapguide-commits
mailing list