|
|
@@ -33,6 +33,7 @@
|
|
|
|
|
|
using System.Collections;
|
|
|
using System.Collections.Specialized;
|
|
|
+using System.Security;
|
|
|
using System.Text;
|
|
|
|
|
|
namespace System.Data.Common {
|
|
|
@@ -42,11 +43,16 @@ namespace System.Data.Common {
|
|
|
#region Fields
|
|
|
|
|
|
internal NameValueCollection options;
|
|
|
+ internal string normalizedConnectionString;
|
|
|
|
|
|
#endregion // Fields
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
+ internal DbConnectionOptions ()
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
[MonoTODO]
|
|
|
protected internal DbConnectionOptions (DbConnectionOptions connectionOptions)
|
|
|
{
|
|
|
@@ -61,7 +67,7 @@ namespace System.Data.Common {
|
|
|
}
|
|
|
|
|
|
[MonoTODO]
|
|
|
- public DbConnectionString (string connectionString, Hashtable synonyms, bool useFirstKeyValuePair)
|
|
|
+ public DbConnectionOptions (string connectionString, Hashtable synonyms, bool useFirstKeyValuePair)
|
|
|
: this (connectionString)
|
|
|
{
|
|
|
}
|
|
|
@@ -149,6 +155,103 @@ namespace System.Data.Common {
|
|
|
throw new NotImplementedException ();
|
|
|
}
|
|
|
|
|
|
+ internal void ParseConnectionString (string connectionString)
|
|
|
+ {
|
|
|
+ if (connectionString.Length == 0)
|
|
|
+ return;
|
|
|
+
|
|
|
+ connectionString += ";";
|
|
|
+
|
|
|
+ bool inQuote = false;
|
|
|
+ bool inDQuote = false;
|
|
|
+ bool inName = true;
|
|
|
+
|
|
|
+ string name = String.Empty;
|
|
|
+ string value = String.Empty;
|
|
|
+ StringBuilder sb = new StringBuilder ();
|
|
|
+
|
|
|
+ for (int i = 0; i < connectionString.Length; i += 1) {
|
|
|
+ char c = connectionString [i];
|
|
|
+ char peek;
|
|
|
+ if (i == connectionString.Length - 1)
|
|
|
+ peek = '\0';
|
|
|
+ else
|
|
|
+ peek = connectionString [i + 1];
|
|
|
+
|
|
|
+ switch (c) {
|
|
|
+ case '\'':
|
|
|
+ if (inDQuote)
|
|
|
+ sb.Append (c);
|
|
|
+ else if (peek.Equals (c)) {
|
|
|
+ sb.Append (c);
|
|
|
+ i += 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ inQuote = !inQuote;
|
|
|
+ break;
|
|
|
+ case '"':
|
|
|
+ if (inQuote)
|
|
|
+ sb.Append (c);
|
|
|
+ else if (peek.Equals (c)) {
|
|
|
+ sb.Append (c);
|
|
|
+ i += 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ inDQuote = !inDQuote;
|
|
|
+ break;
|
|
|
+ case ';':
|
|
|
+ if (inDQuote || inQuote)
|
|
|
+ sb.Append (c);
|
|
|
+ else {
|
|
|
+ if (name != String.Empty && name != null) {
|
|
|
+ value = sb.ToString ();
|
|
|
+ // FIXME - KeywordLookup is an NOP
|
|
|
+ // options [KeywordLookup (name.Trim ())] = value;
|
|
|
+ options [name.Trim ()] = value;
|
|
|
+ }
|
|
|
+ inName = true;
|
|
|
+ name = String.Empty;
|
|
|
+ value = String.Empty;
|
|
|
+ sb = new StringBuilder ();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case '=':
|
|
|
+ if (inDQuote || inQuote || !inName)
|
|
|
+ sb.Append (c);
|
|
|
+ else if (peek.Equals (c)) {
|
|
|
+ sb.Append (c);
|
|
|
+ i += 1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ name = sb.ToString ();
|
|
|
+ sb = new StringBuilder ();
|
|
|
+ inName = false;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ' ':
|
|
|
+ if (inQuote || inDQuote)
|
|
|
+ sb.Append (c);
|
|
|
+ else if (sb.Length > 0 && !peek.Equals (';'))
|
|
|
+ sb.Append (c);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ sb.Append (c);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder normalized = new StringBuilder ();
|
|
|
+ ArrayList keys = new ArrayList ();
|
|
|
+ keys.AddRange (Keys);
|
|
|
+ keys.Sort ();
|
|
|
+ foreach (string key in keys)
|
|
|
+ {
|
|
|
+ string entry = String.Format ("{0}=\"{1}\";", key, this [key].Replace ("\"", "\"\""));
|
|
|
+ normalized.Append (entry);
|
|
|
+ }
|
|
|
+ normalizedConnectionString = normalized.ToString ();
|
|
|
+ }
|
|
|
+
|
|
|
#endregion // Methods
|
|
|
}
|
|
|
}
|