[mapguide-commits] r5061 - in sandbox/maestro-3.0: Maestro.Login MaestroAPITests OSGeo.MapGuide.MaestroAPI

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Jul 30 07:59:06 EDT 2010


Author: jng
Date: 2010-07-30 11:59:06 +0000 (Fri, 30 Jul 2010)
New Revision: 5061

Modified:
   sandbox/maestro-3.0/Maestro.Login/LoginDialog.cs
   sandbox/maestro-3.0/MaestroAPITests/HttpConnectionTests.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ConnectionProviderRegistry.cs
Log:
Port r5060 submission to sandbox


Modified: sandbox/maestro-3.0/Maestro.Login/LoginDialog.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Login/LoginDialog.cs	2010-07-30 11:46:03 UTC (rev 5060)
+++ sandbox/maestro-3.0/Maestro.Login/LoginDialog.cs	2010-07-30 11:59:06 UTC (rev 5061)
@@ -148,12 +148,19 @@
 
                     if (_selectedIndex == 0) //HTTP
                     {
-                        string format = "Url={0};Username={1};Password={2};Locale={3};AllowUntestedVersion={4}";
-                        string connStr = string.Format(format, _http.Server, _http.Username, _http.Password, _http.Language, true);
+                        //string format = "Url={0};Username={1};Password={2};Locale={3};AllowUntestedVersion={4}";
+                        //string connStr = string.Format(format, _http.Server, _http.Username, _http.Password, _http.Language, true);
 
+                        System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder();
+                        builder["Url"] = _http.Server;
+                        builder["Username"] = _http.Username;
+                        builder["Password"] = _http.Password;
+                        builder["Locale"] = _http.Language;
+                        builder["AllowUntestedVersion"] = true;
+
                         string agent = "MapGuide Maestro v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
 
-                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.Http", connStr);
+                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.Http", builder.ToString());
                         _conn.SetCustomProperty("UserAgent", agent);
 
                         //Update preferred site entry if it exists
@@ -209,9 +216,12 @@
                     }
                     else //Native
                     {
-                        string format = "WebConfig={0};Username={1};Password={2};Locale={3}";
-                        string connStr = string.Format(format, _local.WebConfigPath, _local.Username, _local.Password, System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
-                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.LocalNative", connStr);
+                        System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder();
+                        builder["WebConfig"] = _local.WebConfigPath;
+                        builder["Username"] = _local.Username;
+                        builder["Password"] = _local.Password;
+                        builder["Locale"] = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
+                        _conn = ConnectionProviderRegistry.CreateConnection("Maestro.LocalNative", builder.ToString());
                     }
 
                     _conn.AutoRestartSession = true;

Modified: sandbox/maestro-3.0/MaestroAPITests/HttpConnectionTests.cs
===================================================================
--- sandbox/maestro-3.0/MaestroAPITests/HttpConnectionTests.cs	2010-07-30 11:46:03 UTC (rev 5060)
+++ sandbox/maestro-3.0/MaestroAPITests/HttpConnectionTests.cs	2010-07-30 11:59:06 UTC (rev 5061)
@@ -30,6 +30,24 @@
     public class HttpConnectionTests
     {
         [Test]
+        public void TestConnectionString()
+        {
+            System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder();
+            builder["Foo"] = "sdfjkg";
+            builder["Bar"] = "skgjuksdf";
+            builder["Snafu"] = "asjdgjh;sdgj"; //Note the ; in the value
+            builder["Whatever"] = "asjd=gjh;sdgj"; //Note the ; and = in the value
+
+            var values = ConnectionProviderRegistry.ParseConnectionString(builder.ToString());
+            Assert.AreEqual(values.Count, 4);
+
+            Assert.AreEqual(builder["Foo"].ToString(), values["Foo"]);
+            Assert.AreEqual(builder["Bar"].ToString(), values["Bar"]);
+            Assert.AreEqual(builder["Snafu"].ToString(), values["Snafu"]);
+            Assert.AreEqual(builder["Whatever"].ToString(), values["Whatever"]);
+        }
+
+        [Test]
         public void TestCustomProperties()
         {
             var builder = new RequestBuilder(new Uri("http://tempuri.org"), "en");

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ConnectionProviderRegistry.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ConnectionProviderRegistry.cs	2010-07-30 11:46:03 UTC (rev 5060)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ConnectionProviderRegistry.cs	2010-07-30 11:59:06 UTC (rev 5061)
@@ -97,18 +97,16 @@
             }
         }
 
-        private static NameValueCollection ParseConnectionString(string connectionString)
+        internal static NameValueCollection ParseConnectionString(string connectionString)
         {
+            System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder();
+            builder.ConnectionString = connectionString;
+
             NameValueCollection values = new NameValueCollection();
-            string[] tokens = connectionString.Split(';');
-            foreach (string tok in tokens)
-            {
-                string[] nameValue = tok.Split('=');
 
-                if (nameValue.Length == 2)
-                {
-                    values.Add(nameValue[0], nameValue[1]);
-                }
+            foreach (string key in builder.Keys)
+            {
+                values.Add(key, builder[key].ToString());
             }
             return values;
         }



More information about the mapguide-commits mailing list