[pgsqlclient-checkins] SF.net SVN: pgsqlclient: [103] trunk/PostgreSqlClient/source/PostgreSql/Data/
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2006-04-12 13:42:10
|
Revision: 103 Author: carlosga_fb Date: 2006-04-12 06:41:56 -0700 (Wed, 12 Apr 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=103&view=rev Log Message: ----------- ?\194?\183 Changes on Connection String parameter handling Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/PostgreSqlClient/PgConnectionStringBuilder.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/PostgreSqlClient/PgConnectionStringBuilder.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PostgreSqlClient/PgConnectionStringBuilder.cs 2006-04-12 13:41:07 UTC (rev 102) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PostgreSqlClient/PgConnectionStringBuilder.cs 2006-04-12 13:41:56 UTC (rev 103) @@ -16,85 +16,124 @@ */ using System; +using System.Collections; using System.Data; using System.Data.Common; namespace PostgreSql.Data.PostgreSqlClient { public sealed class PgConnectionStringBuilder : DbConnectionStringBuilder - { + { + #region \xB7 Static Fields \xB7 + + static readonly Hashtable Synonyms = InitializeSynonyms(); + + #endregion + + #region \xB7 Static Methods \xB7 + + static Hashtable InitializeSynonyms() + { + Hashtable synonyms = new Hashtable(); + + synonyms.Add("data source", "data source"); + synonyms.Add("server", "data source"); + synonyms.Add("host", "data source"); + synonyms.Add("host", "data source"); + synonyms.Add("database", "catalog"); + synonyms.Add("catalog", "catalog"); + synonyms.Add("user id", "user id"); + synonyms.Add("user name", "user id"); + synonyms.Add("user", "user id"); + synonyms.Add("user password", "password"); + synonyms.Add("password", "password"); + synonyms.Add("port number", "port number"); + synonyms.Add("port", "port number"); + synonyms.Add("packet size", "packet size"); + synonyms.Add("connection timeout", "connection timeout"); + synonyms.Add("pooling", "pooling"); + synonyms.Add("connection lifetime", "connection lifetime"); + synonyms.Add("min pool size", "min pool size"); + synonyms.Add("max pool size", "max pool size"); + synonyms.Add("ssl", "ssl"); + + return synonyms; + } + + #endregion + #region \xB7 Properties \xB7 public string DataSource { get { return this.GetString("Data Source"); } - set { this["Data Source"] = value; } + set { this.SetValue("Data Source", value); } } public string Catalog { get { return this.GetString("Catalog"); } - set { this["Catalog"] = value; } + set { this.SetValue("Catalog", value); } } public string UserID { get { return this.GetString("User ID"); } - set { this["User ID"] = value; } + set { this.SetValue("User ID", value); } } public string Password { get { return this.GetString("Password"); } - set { this["Password"] = value; } + set { this.SetValue("Password", value); } } - public int Port + public int PortNumber { get { return this.GetInt32("Port Number"); } - set { this["Port Number"] = value; } + set { this.SetValue("Port Number", value); } } public int PacketSize { get { return this.GetInt32("Packet Size"); } - set { this["Packet Size"] = value; } + set { this.SetValue("Packet Size", value); } } public int ConnectionTimeout { get { return this.GetInt32("Connection Timeout"); } - set { this["Connection Timeout"] = value; } + set { this.SetValue("Connection Timeout", value); } } public bool Pooling { get { return this.GetBoolean("Pooling"); } - set { this["Pooling"] = value; } + set { this.SetValue("Pooling", value); } } public int ConnectionLifeTime { get { return this.GetInt32("Connection Lifetime"); } - set { this["Connection Lifetime"] = value; } + set { this.SetValue("Connection Lifetime", value); } } public int MinPoolSize { get { return this.GetInt32("Min Pool Size"); } - set { this["Min Pool Size"] = value; } + set { this.SetValue("Min Pool Size", value); } } public int MaxPoolSize { get { return this.GetInt32("Max Pool Size"); } - set { this["Max Pool Size"] = value; } + set { this.SetValue("Max Pool Size", value); } } public bool Ssl { - get { return this.GetBoolean("SSL"); } - set { this["SSL"] = value; } + get { return this.GetBoolean("Ssl"); } + set { this.SetValue("Ssl", value); } } #endregion @@ -116,19 +155,41 @@ private int GetInt32(string keyword) { - return Convert.ToInt32(this[keyword]); + return Convert.ToInt32(this.GetKey(keyword)); } private string GetString(string keyword) { - return Convert.ToString(this[keyword]); + return Convert.ToString(this.GetKey(keyword)); } private bool GetBoolean(string keyword) { - return Convert.ToBoolean(this[keyword]); + return Convert.ToBoolean(this.GetKey(keyword)); } + private void SetValue(string keyword, object value) + { + this[this.GetKey(keyword)] = value; + } + + private string GetKey(string keyword) + { + string synonymKey = (string)Synonyms[keyword]; + + // First check if there are yet a property for the requested keyword + foreach (string key in this.Keys) + { + if (Synonyms.ContainsKey(key) && (string)Synonyms[key] == synonymKey) + { + synonymKey = key; + break; + } + } + + return synonymKey; + } + #endregion } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |