2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.Data / System.Data.SqlClient / SqlConnectionStringBuilder.cs
blob57450cdae53fe5118389c7891a5bc3ffad886ba6
1 //
2 // System.Data.SqlClient.SqlConnectionStringBuilder.cs
3 //
4 // Author:
5 // Sureshkumar T (tsureshkumar@novell.com)
6 //
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #if NET_2_0
30 using System;
31 using System.Text;
32 using System.Collections;
33 using System.Collections.Generic;
34 using System.Collections.ObjectModel;
36 using System.Data;
37 using System.Data.Common;
38 using System.ComponentModel;
40 namespace System.Data.SqlClient
42 [DefaultPropertyAttribute ("DataSource")]
43 #if NET_2_0
44 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlConnectionStringBuilderConverter, " + Consts.AssemblySystem_Data)]
45 #endif
46 public sealed class SqlConnectionStringBuilder : DbConnectionStringBuilder
49 private const string DEF_APPLICATIONNAME = ".NET SqlClient Data Provider";
50 private const bool DEF_ASYNCHRONOUSPROCESSING = false;
51 private const string DEF_ATTACHDBFILENAME = "";
52 private const bool DEF_CONNECTIONRESET = true;
53 private const int DEF_CONNECTTIMEOUT = 15;
54 private const string DEF_CURRENTLANGUAGE = "";
55 private const string DEF_DATASOURCE = "";
56 private const bool DEF_ENCRYPT = false;
57 private const bool DEF_ENLIST = false;
58 private const string DEF_FAILOVERPARTNER = "";
59 private const string DEF_INITIALCATALOG = "";
60 private const bool DEF_INTEGRATEDSECURITY = false;
61 private const int DEF_LOADBALANCETIMEOUT = 0;
62 private const int DEF_MAXPOOLSIZE = 100;
63 private const int DEF_MINPOOLSIZE = 0;
64 private const bool DEF_MULTIPLEACTIVERESULTSETS = false;
65 private const string DEF_NETWORKLIBRARY = "";
66 private const int DEF_PACKETSIZE = 8000;
67 private const string DEF_PASSWORD = "";
68 private const bool DEF_PERSISTSECURITYINFO = false;
69 private const bool DEF_POOLING = true;
70 private const bool DEF_REPLICATION = false;
71 private const string DEF_USERID = "";
72 private const string DEF_WORKSTATIONID = "";
73 private const string DEF_TYPESYSTEMVERSION = "Latest";
74 private const bool DEF_TRUSTSERVERCERTIFICATE = false;
75 private const bool DEF_USERINSTANCE = false;
76 private const bool DEF_CONTEXTCONNECTION = false;
77 private const string DEF_TRANSACTIONBINDING = "Implicit Unbind";
80 #region // Fields
81 private string _applicationName;
82 private bool _asynchronousProcessing;
83 private string _attachDBFilename;
84 private bool _connectionReset;
85 private int _connectTimeout;
86 private string _currentLanguage;
87 private string _dataSource;
88 private bool _encrypt;
89 private bool _enlist;
90 private string _failoverPartner;
91 private string _initialCatalog;
92 private bool _integratedSecurity;
93 private int _loadBalanceTimeout;
94 private int _maxPoolSize;
95 private int _minPoolSize;
96 private bool _multipleActiveResultSets;
97 private string _networkLibrary;
98 private int _packetSize;
99 private string _password;
100 private bool _persistSecurityInfo;
101 private bool _pooling;
102 private bool _replication;
103 private string _userID;
104 private string _workstationID;
105 private bool _trustServerCertificate;
106 private string _typeSystemVersion;
107 private bool _userInstance;
108 private bool _contextConnection;
109 private string _transactionBinding;
111 private static Dictionary <string, string> _keywords; // for mapping duplicate keywords
112 private static Dictionary <string, object> _defaults;
113 #endregion // Fields
115 #region Constructors
116 public SqlConnectionStringBuilder () : this (String.Empty)
120 public SqlConnectionStringBuilder (string connectionString)
122 Init ();
123 base.ConnectionString = connectionString;
126 static SqlConnectionStringBuilder ()
128 _keywords = new Dictionary <string, string> ();
129 _keywords ["APP"] = "Application Name";
130 _keywords ["APPLICATION NAME"] = "Application Name";
131 _keywords ["ATTACHDBFILENAME"] = "AttachDbFilename";
132 _keywords ["EXTENDED PROPERTIES"] = "Extended Properties";
133 _keywords ["INITIAL FILE NAME"] = "Initial File Name";
134 _keywords ["TIMEOUT"] = "Connect Timeout";
135 _keywords ["CONNECT TIMEOUT"] = "Connect Timeout";
136 _keywords ["CONNECTION TIMEOUT"] = "Connect Timeout";
137 _keywords ["CONNECTION RESET"] = "Connection Reset";
138 _keywords ["LANGUAGE"] = "Current Language";
139 _keywords ["CURRENT LANGUAGE"] = "Current Language";
140 _keywords ["DATA SOURCE"] = "Data Source";
141 _keywords ["SERVER"] = "Data Source";
142 _keywords ["ADDRESS"] = "Data Source";
143 _keywords ["ADDR"] = "Data Source";
144 _keywords ["NETWORK ADDRESS"] = "Data Source";
145 _keywords ["ENCRYPT"] = "Encrypt";
146 _keywords ["ENLIST"] = "Enlist";
147 _keywords ["INITIAL CATALOG"] = "Initial Catalog";
148 _keywords ["DATABASE"] = "Initial Catalog";
149 _keywords ["INTEGRATED SECURITY"] = "Integrated Security";
150 _keywords ["TRUSTED_CONNECTION"] = "Integrated Security";
151 _keywords ["MAX POOL SIZE"] = "Max Pool Size";
152 _keywords ["MIN POOL SIZE"] = "Min Pool Size";
153 _keywords ["MULTIPLEACTIVERESULTSETS"] = "MultipleActiveResultSets";
154 _keywords ["ASYNCHRONOUS PROCESSING"] = "Asynchronous Processing";
155 _keywords ["ASYNC"] = "Async";
156 _keywords ["NET"] = "Network Library";
157 _keywords ["NETWORK"] = "Network Library";
158 _keywords ["NETWORK LIBRARY"] = "Network Library";
159 _keywords ["PACKET SIZE"] = "Packet Size";
160 _keywords ["PASSWORD"] = "Password";
161 _keywords ["PWD"] = "Password";
162 _keywords ["PERSISTSECURITYINFO"] = "Persist Security Info";
163 _keywords ["PERSIST SECURITY INFO"] = "Persist Security Info";
164 _keywords ["POOLING"] = "Pooling";
165 _keywords ["UID"] = "User ID";
166 _keywords ["USER"] = "User ID";
167 _keywords ["USER ID"] = "User ID";
168 _keywords ["WSID"] = "Workstation ID";
169 _keywords ["WORKSTATION ID"] = "Workstation ID";
170 _keywords ["USER INSTANCE"] = "User Instance";
171 _keywords ["CONTEXT CONNECTION"] = "Context Connection";
172 _keywords ["TRANSACTION BINDING"] = "Transaction Binding";
173 _keywords ["FAILOVER PARTNER"] = "Failover Partner";
174 _keywords ["REPLICATION"] = "Replication";
175 _keywords ["TRUSTSERVERCERTIFICATE"] = "TrustServerCertificate";
176 _keywords ["LOAD BALANCE TIMEOUT"] = "Load Balance Timeout";
177 _keywords ["TYPE SYSTEM VERSION"] = "Type System Version";
179 _defaults = new Dictionary<string, object> ();
180 _defaults.Add("Data Source", DEF_DATASOURCE);
181 _defaults.Add("Failover Partner", DEF_FAILOVERPARTNER);
182 _defaults.Add("AttachDbFilename", DEF_ATTACHDBFILENAME);
183 _defaults.Add("Initial Catalog", DEF_INITIALCATALOG);
184 _defaults.Add("Integrated Security", DEF_INTEGRATEDSECURITY);
185 _defaults.Add("Persist Security Info", DEF_PERSISTSECURITYINFO);
186 _defaults.Add("User ID", DEF_USERID);
187 _defaults.Add("Password", DEF_PASSWORD);
188 _defaults.Add("Enlist", DEF_ENLIST);
189 _defaults.Add("Pooling", DEF_POOLING);
190 _defaults.Add("Min Pool Size", DEF_MINPOOLSIZE);
191 _defaults.Add("Max Pool Size", DEF_MAXPOOLSIZE);
192 _defaults.Add("Asynchronous Processing", DEF_ASYNCHRONOUSPROCESSING);
193 _defaults.Add("Connection Reset", DEF_CONNECTIONRESET);
194 _defaults.Add("MultipleActiveResultSets", DEF_MULTIPLEACTIVERESULTSETS);
195 _defaults.Add("Replication", DEF_REPLICATION);
196 _defaults.Add("Connect Timeout", DEF_CONNECTTIMEOUT);
197 _defaults.Add("Encrypt", DEF_ENCRYPT);
198 _defaults.Add("TrustServerCertificate", DEF_TRUSTSERVERCERTIFICATE);
199 _defaults.Add("Load Balance Timeout", DEF_LOADBALANCETIMEOUT);
200 _defaults.Add("Network Library", DEF_NETWORKLIBRARY);
201 _defaults.Add("Packet Size", DEF_PACKETSIZE);
202 _defaults.Add("Type System Version", DEF_TYPESYSTEMVERSION);
203 _defaults.Add("Application Name", DEF_APPLICATIONNAME);
204 _defaults.Add("Current Language", DEF_CURRENTLANGUAGE);
205 _defaults.Add("Workstation ID", DEF_WORKSTATIONID);
206 _defaults.Add("User Instance", DEF_USERINSTANCE);
207 _defaults.Add("Context Connection", DEF_CONTEXTCONNECTION);
208 _defaults.Add("Transaction Binding", DEF_TRANSACTIONBINDING);
210 #endregion // Constructors
212 #region Properties
213 [DisplayNameAttribute ("Application Name")]
214 [RefreshPropertiesAttribute (RefreshProperties.All)]
215 public string ApplicationName {
216 get { return _applicationName; }
217 set {
218 base ["Application Name"] = value;
219 _applicationName = value;
223 [DisplayNameAttribute ("Asynchronous Processing")]
224 [RefreshPropertiesAttribute (RefreshProperties.All)]
225 public bool AsynchronousProcessing {
226 get { return _asynchronousProcessing; }
227 set {
228 base ["Asynchronous Processing"] = value;
229 _asynchronousProcessing = value;
233 #if NET_2_0
234 [Editor ("System.Windows.Forms.Design.FileNameEditor, " + Consts.AssemblySystem_Design,
235 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
236 #else
237 [Editor ("Microsoft.VSDesigner.Data.Design.DBParametersEditor, " + Consts.AssemblyMicrosoft_VSDesigner,
238 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
239 #endif
240 [DisplayNameAttribute ("AttachDbFilename")]
241 [RefreshPropertiesAttribute (RefreshProperties.All)]
242 public string AttachDBFilename {
243 get { return _attachDBFilename; }
244 set {
245 base ["AttachDbFilename"] = value;
246 _attachDBFilename = value;
250 [DisplayNameAttribute ("Connection Reset")]
251 [RefreshPropertiesAttribute (RefreshProperties.All)]
252 public bool ConnectionReset {
253 get { return _connectionReset; }
254 set {
255 base ["Connection Reset"] = value;
256 _connectionReset = value;
260 [DisplayNameAttribute ("Connect Timeout")]
261 [RefreshPropertiesAttribute (RefreshProperties.All)]
262 public int ConnectTimeout {
263 get { return _connectTimeout; }
264 set {
265 base ["Connect Timeout"] = value;
266 _connectTimeout = value;
270 [DisplayNameAttribute ("Current Language")]
271 [RefreshPropertiesAttribute (RefreshProperties.All)]
272 public string CurrentLanguage {
273 get { return _currentLanguage; }
274 set {
275 base ["Current Language"] = value;
276 _currentLanguage = value;
280 [DisplayNameAttribute ("Data Source")]
281 [RefreshPropertiesAttribute (RefreshProperties.All)]
282 #if NET_2_0
283 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlDataSourceConverter, " + Consts.AssemblySystem_Data)]
284 #endif
285 public string DataSource {
286 get { return _dataSource; }
287 set {
288 base ["Data Source"] = value;
289 _dataSource = value;
293 [DisplayNameAttribute ("Encrypt")]
294 [RefreshPropertiesAttribute (RefreshProperties.All)]
295 public bool Encrypt {
296 get { return _encrypt; }
297 set {
298 base ["Encrypt"] = value;
299 _encrypt = value;
303 [DisplayNameAttribute ("Enlist")]
304 [RefreshPropertiesAttribute (RefreshProperties.All)]
305 public bool Enlist {
306 get { return _enlist; }
307 set {
308 base ["Enlist"] = value;
309 _enlist = value;
313 [DisplayNameAttribute ("Failover Partner")]
314 [RefreshPropertiesAttribute (RefreshProperties.All)]
315 #if NET_2_0
316 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlDataSourceConverter, " + Consts.AssemblySystem_Data)]
317 #endif
318 public string FailoverPartner {
319 get { return _failoverPartner; }
320 set {
321 base ["Failover Partner"] = value;
322 _failoverPartner = value;
326 [DisplayNameAttribute ("Initial Catalog")]
327 [RefreshPropertiesAttribute (RefreshProperties.All)]
328 #if NET_2_0
329 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlInitialCatalogConverter, " + Consts.AssemblySystem_Data)]
330 #endif
331 public string InitialCatalog {
332 get { return _initialCatalog; }
333 set {
334 base ["Initial Catalog"] = value;
335 _initialCatalog = value;
339 [DisplayNameAttribute ("Integrated Security")]
340 [RefreshPropertiesAttribute (RefreshProperties.All)]
341 public bool IntegratedSecurity {
342 get { return _integratedSecurity; }
343 set {
344 base ["Integrated Security"] = value;
345 _integratedSecurity = value;
349 public override bool IsFixedSize {
350 get { return true; }
353 public override object this [string keyword] {
354 get {
355 string mapped = MapKeyword (keyword);
356 if (base.ContainsKey (mapped))
357 return base [mapped];
358 else
359 return _defaults [mapped];
361 set {SetValue (keyword, value);}
364 public override ICollection Keys {
365 get {
366 List<string> keys = new List<string>();
367 keys.Add("Data Source");
368 keys.Add("Failover Partner");
369 keys.Add("AttachDbFilename");
370 keys.Add("Initial Catalog");
371 keys.Add("Integrated Security");
372 keys.Add("Persist Security Info");
373 keys.Add("User ID");
374 keys.Add("Password");
375 keys.Add("Enlist");
376 keys.Add("Pooling");
377 keys.Add("Min Pool Size");
378 keys.Add("Max Pool Size");
379 keys.Add("Asynchronous Processing");
380 keys.Add("Connection Reset");
381 keys.Add("MultipleActiveResultSets");
382 keys.Add("Replication");
383 keys.Add("Connect Timeout");
384 keys.Add("Encrypt");
385 keys.Add("TrustServerCertificate");
386 keys.Add("Load Balance Timeout");
387 keys.Add("Network Library");
388 keys.Add("Packet Size");
389 keys.Add("Type System Version");
390 keys.Add("Application Name");
391 keys.Add("Current Language");
392 keys.Add("Workstation ID");
393 keys.Add("User Instance");
394 keys.Add("Context Connection");
395 keys.Add("Transaction Binding");
396 ReadOnlyCollection<string> coll = new ReadOnlyCollection<string>(keys);
397 return coll;
401 [DisplayNameAttribute ("Load Balance Timeout")]
402 [RefreshPropertiesAttribute (RefreshProperties.All)]
403 public int LoadBalanceTimeout {
404 get { return _loadBalanceTimeout; }
405 set {
406 base ["Load Balance Timeout"] = value;
407 _loadBalanceTimeout = value;
411 [DisplayNameAttribute ("Max Pool Size")]
412 [RefreshPropertiesAttribute (RefreshProperties.All)]
413 public int MaxPoolSize {
414 get { return _maxPoolSize; }
415 set {
416 base ["Max Pool Size"] = value;
417 _maxPoolSize = value;
421 [DisplayNameAttribute ("Min Pool Size")]
422 [RefreshPropertiesAttribute (RefreshProperties.All)]
423 public int MinPoolSize {
424 get { return _minPoolSize; }
425 set {
426 base ["Min Pool Size"] = value;
427 _minPoolSize = value;
431 [DisplayNameAttribute ("MultipleActiveResultSets")]
432 [RefreshPropertiesAttribute (RefreshProperties.All)]
433 public bool MultipleActiveResultSets {
434 get { return _multipleActiveResultSets; }
435 set {
436 base ["Multiple Active Resultsets"] = value;
437 _multipleActiveResultSets = value;
441 [DisplayNameAttribute ("Network Library")]
442 [RefreshPropertiesAttribute (RefreshProperties.All)]
443 #if NET_2_0
444 [TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+NetworkLibraryConverter, " + Consts.AssemblySystem_Data)]
445 #endif
446 public string NetworkLibrary {
447 get { return _networkLibrary; }
448 set {
449 base ["Network Library"] = value;
450 _networkLibrary = value;
454 [DisplayNameAttribute ("Packet Size")]
455 [RefreshPropertiesAttribute (RefreshProperties.All)]
456 public int PacketSize {
457 get { return _packetSize; }
458 set {
459 base ["Packet Size"] = value;
460 _packetSize = value;
464 [DisplayNameAttribute ("Password")]
465 [PasswordPropertyTextAttribute (true)]
466 [RefreshPropertiesAttribute (RefreshProperties.All)]
467 public string Password {
468 get { return _password; }
469 set {
470 base ["Password"] = value;
471 _password = value;
475 [DisplayNameAttribute ("Persist Security Info")]
476 [RefreshPropertiesAttribute (RefreshProperties.All)]
477 public bool PersistSecurityInfo {
478 get { return _persistSecurityInfo; }
479 set {
480 base ["Persist Security Info"] = value;
481 _persistSecurityInfo = value;
485 [DisplayNameAttribute ("Pooling")]
486 [RefreshPropertiesAttribute (RefreshProperties.All)]
487 public bool Pooling {
488 get { return _pooling; }
489 set {
490 base ["Pooling"] = value;
491 _pooling = value;
495 [DisplayNameAttribute ("Replication")]
496 [RefreshPropertiesAttribute (RefreshProperties.All)]
497 public bool Replication {
498 get { return _replication; }
499 set {
500 base ["Replication"] = value;
501 _replication = value;
505 [DisplayNameAttribute ("User ID")]
506 [RefreshPropertiesAttribute (RefreshProperties.All)]
507 public string UserID {
508 get { return _userID; }
509 set {
510 base ["User Id"]= value;
511 _userID = value;
515 public override ICollection Values {
516 get {
517 List<object> values = new List<object>();
518 values.Add(_dataSource);
519 values.Add(_failoverPartner);
520 values.Add(_attachDBFilename);
521 values.Add(_initialCatalog);
522 values.Add(_integratedSecurity);
523 values.Add(_persistSecurityInfo);
524 values.Add(_userID);
525 values.Add(_password);
526 values.Add(_enlist);
527 values.Add(_pooling);
528 values.Add(_minPoolSize);
529 values.Add(_maxPoolSize);
530 values.Add(_asynchronousProcessing);
531 values.Add(_connectionReset);
532 values.Add(_multipleActiveResultSets);
533 values.Add(_replication);
534 values.Add(_connectTimeout);
535 values.Add(_encrypt);
536 values.Add(_trustServerCertificate);
537 values.Add(_loadBalanceTimeout);
538 values.Add(_networkLibrary);
539 values.Add(_packetSize);
540 values.Add(_typeSystemVersion);
541 values.Add(_applicationName);
542 values.Add(_currentLanguage);
543 values.Add(_workstationID);
544 values.Add(_userInstance);
545 values.Add(_contextConnection);
546 values.Add(_transactionBinding);
547 ReadOnlyCollection<object> coll = new ReadOnlyCollection<object>(values);
548 return coll;
552 [DisplayNameAttribute ("Workstation ID")]
553 [RefreshPropertiesAttribute (RefreshProperties.All)]
554 public string WorkstationID {
555 get { return _workstationID; }
556 set {
557 base ["Workstation Id"] = value;
558 _workstationID = value;
562 [DisplayNameAttribute ("TrustServerCertificate")]
563 [RefreshProperties (RefreshProperties.All)]
564 public bool TrustServerCertificate {
565 get { return _trustServerCertificate; }
566 set {
567 base ["Trust Server Certificate"] = value;
568 _trustServerCertificate = value;
572 [DisplayNameAttribute ("Type System Version")]
573 [RefreshProperties (RefreshProperties.All)]
574 public string TypeSystemVersion {
575 get { return _typeSystemVersion; }
576 set {
577 base ["Type System Version"] = value;
578 _typeSystemVersion = value;
582 [DisplayNameAttribute ("User Instance")]
583 [RefreshProperties (RefreshProperties.All)]
584 public bool UserInstance {
585 get { return _userInstance; }
586 set {
587 base ["User Instance"] = value;
588 _userInstance = value;
592 [RefreshPropertiesAttribute (RefreshProperties.All)]
593 [DisplayNameAttribute ("Context Connection")]
594 public bool ContextConnection {
595 get { return _contextConnection; }
596 set {
597 base ["Context Connection"] = value;
598 _contextConnection = value;
601 #endregion // Properties
603 #region Methods
604 private void Init ()
606 _applicationName = DEF_APPLICATIONNAME;
607 _asynchronousProcessing = DEF_ASYNCHRONOUSPROCESSING;
608 _attachDBFilename = DEF_ATTACHDBFILENAME;
609 _connectionReset = DEF_CONNECTIONRESET;
610 _connectTimeout = DEF_CONNECTTIMEOUT;
611 _currentLanguage = DEF_CURRENTLANGUAGE;
612 _dataSource = DEF_DATASOURCE;
613 _encrypt = DEF_ENCRYPT;
614 _enlist = DEF_ENLIST;
615 _failoverPartner = DEF_FAILOVERPARTNER;
616 _initialCatalog = DEF_INITIALCATALOG;
617 _integratedSecurity = DEF_INTEGRATEDSECURITY;
618 _loadBalanceTimeout = DEF_LOADBALANCETIMEOUT;
619 _maxPoolSize = DEF_MAXPOOLSIZE;
620 _minPoolSize = DEF_MINPOOLSIZE;
621 _multipleActiveResultSets= DEF_MULTIPLEACTIVERESULTSETS;
622 _networkLibrary = DEF_NETWORKLIBRARY;
623 _packetSize = DEF_PACKETSIZE;
624 _password = DEF_PASSWORD;
625 _persistSecurityInfo = DEF_PERSISTSECURITYINFO;
626 _pooling = DEF_POOLING;
627 _replication = DEF_REPLICATION;
628 _userID = DEF_USERID;
629 _workstationID = DEF_WORKSTATIONID;
630 _trustServerCertificate = DEF_TRUSTSERVERCERTIFICATE;
631 _typeSystemVersion = DEF_TYPESYSTEMVERSION;
632 _userInstance = DEF_USERINSTANCE;
633 _contextConnection = DEF_CONTEXTCONNECTION;
634 _transactionBinding = DEF_TRANSACTIONBINDING;
637 public override void Clear ()
639 base.Clear ();
640 Init ();
643 public override bool ContainsKey (string keyword)
645 keyword = keyword.ToUpper ().Trim ();
646 if (_keywords.ContainsKey (keyword))
647 return base.ContainsKey (_keywords [keyword]);
648 return false;
651 public override bool Remove (string keyword)
653 if (!ContainsKey (keyword))
654 return false;
655 this [keyword] = null;
656 return true;
659 [MonoNotSupported ("")] // Note that base.ShouldSerialize() is called but not implemented
660 public override bool ShouldSerialize (string keyword)
662 if (!ContainsKey (keyword))
663 return false;
664 keyword = keyword.ToUpper ().Trim ();
665 // Assuming passwords cannot be serialized.
666 if (_keywords [keyword] == "Password")
667 return false;
668 return base.ShouldSerialize (_keywords [keyword]);
671 public override bool TryGetValue (string keyword, out object value)
673 if (! ContainsKey (keyword)) {
674 value = String.Empty;
675 return false;
677 return base.TryGetValue (_keywords [keyword.ToUpper ().Trim ()], out value);
680 #endregion // Methods
682 #region Private Methods
683 private string MapKeyword (string keyword)
685 keyword = keyword.ToUpper ().Trim ();
686 if (! _keywords.ContainsKey (keyword))
687 throw new ArgumentException("Keyword not supported :" + keyword);
688 return _keywords [keyword];
691 private void SetValue (string key, object value)
693 if (key == null)
694 throw new ArgumentNullException ("key cannot be null!");
696 string mappedKey = MapKeyword (key);
698 switch (mappedKey.ToUpper ().Trim ()) {
699 case "APPLICATION NAME" :
700 if (value == null) {
701 _applicationName = DEF_APPLICATIONNAME;
702 base.Remove (mappedKey);
703 } else
704 this.ApplicationName = value.ToString ();
705 break;
706 case "ATTACHDBFILENAME" :
707 throw new NotImplementedException ("Attachable database support is " +
708 "not implemented.");
709 case "CONNECT TIMEOUT" :
710 if (value == null) {
711 _connectTimeout = DEF_CONNECTTIMEOUT;
712 base.Remove (mappedKey);
713 } else
714 this.ConnectTimeout = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
715 break;
716 case "CONNECTION LIFETIME" :
717 break;
718 case "CONNECTION RESET" :
719 if (value == null) {
720 _connectionReset = DEF_CONNECTIONRESET;
721 base.Remove (mappedKey);
722 } else
723 this.ConnectionReset = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
724 break;
725 case "CURRENT LANGUAGE" :
726 if (value == null) {
727 _currentLanguage = DEF_CURRENTLANGUAGE;
728 base.Remove (mappedKey);
729 } else
730 this.CurrentLanguage = value.ToString ();
731 break;
732 case "CONTEXT CONNECTION" :
733 if (value == null) {
734 _contextConnection = DEF_CONTEXTCONNECTION;
735 base.Remove (mappedKey);
736 } else
737 this.ContextConnection = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
738 break;
739 case "DATA SOURCE" :
740 if (value == null) {
741 _dataSource = DEF_DATASOURCE;
742 base.Remove (mappedKey);
743 } else
744 this.DataSource = value.ToString ();
745 break;
746 case "ENCRYPT":
747 if (value == null) {
748 _encrypt = DEF_ENCRYPT;
749 base.Remove (mappedKey);
750 }else if (DbConnectionStringBuilderHelper.ConvertToBoolean(value))
751 throw new NotImplementedException("SSL encryption for"
752 + " data sent between client and server is not"
753 + " implemented.");
754 break;
755 case "ENLIST" :
756 if (value == null) {
757 _enlist = DEF_ENLIST;
758 base.Remove (mappedKey);
759 } else if ( ! DbConnectionStringBuilderHelper.ConvertToBoolean(value))
760 throw new NotImplementedException("Disabling the automatic"
761 + " enlistment of connections in the thread's current"
762 + " transaction context is not implemented.");
763 break;
764 case "INITIAL CATALOG" :
765 if (value == null) {
766 _initialCatalog = DEF_INITIALCATALOG;
767 base.Remove (mappedKey);
768 } else
769 this.InitialCatalog = value.ToString ();
770 break;
771 case "INTEGRATED SECURITY" :
772 if (value == null) {
773 _integratedSecurity = DEF_INTEGRATEDSECURITY;
774 base.Remove (mappedKey);
775 } else
776 this.IntegratedSecurity = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
777 break;
778 case "MAX POOL SIZE" :
779 if (value == null) {
780 _maxPoolSize = DEF_MAXPOOLSIZE;
781 base.Remove (mappedKey);
782 } else
783 this.MaxPoolSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
784 break;
785 case "MIN POOL SIZE" :
786 if (value == null) {
787 _minPoolSize = DEF_MINPOOLSIZE;
788 base.Remove (mappedKey);
789 } else
790 this.MinPoolSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
791 break;
792 case "MULTIPLEACTIVERESULTSETS":
793 if (value == null) {
794 _multipleActiveResultSets = DEF_MULTIPLEACTIVERESULTSETS;
795 base.Remove (mappedKey);
796 } else if ( DbConnectionStringBuilderHelper.ConvertToBoolean (value))
797 throw new NotImplementedException ("MARS is not yet implemented!");
798 break;
799 case "ASYNCHRONOUS PROCESSING" :
800 if (value == null) {
801 _asynchronousProcessing = DEF_ASYNCHRONOUSPROCESSING;
802 base.Remove (mappedKey);
803 } else
804 this.AsynchronousProcessing = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
805 break;
806 case "NETWORK LIBRARY" :
807 if (value == null) {
808 _networkLibrary = DEF_NETWORKLIBRARY;
809 base.Remove (mappedKey);
810 } else {
811 if (!value.ToString ().ToUpper ().Equals ("DBMSSOCN"))
812 throw new ArgumentException ("Unsupported network library.");
813 this.NetworkLibrary = value.ToString ().ToLower ();
815 break;
816 case "LOAD BALANCE TIMEOUT":
817 // TODO: what is this?
818 break;
819 case "PACKET SIZE" :
820 if (value == null) {
821 _packetSize = DEF_PACKETSIZE;
822 base.Remove (mappedKey);
823 } else
824 this.PacketSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
825 break;
826 case "PASSWORD" :
827 if (value == null) {
828 _password = DEF_PASSWORD;
829 base.Remove (mappedKey);
830 } else
831 this.Password = value.ToString ();
832 break;
833 case "PERSIST SECURITY INFO" :
834 if (value == null) {
835 _persistSecurityInfo = DEF_PERSISTSECURITYINFO;
836 base.Remove (mappedKey);
837 } else if (DbConnectionStringBuilderHelper.ConvertToBoolean (value))
838 throw new NotImplementedException ("Persisting security info" +
839 " is not yet implemented");
840 break;
841 case "POOLING" :
842 if (value == null) {
843 _pooling = DEF_POOLING;
844 base.Remove (mappedKey);
845 } else
846 this.Pooling = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
847 break;
848 case "USER ID" :
849 if (value == null) {
850 _userID = DEF_USERID;
851 base.Remove (mappedKey);
852 } else
853 this.UserID = value.ToString ();
854 break;
855 case "USER INSTANCE" :
856 if (value == null) {
857 _userInstance = DEF_USERINSTANCE;
858 base.Remove (mappedKey);
859 } else
860 this.UserInstance = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
861 break;
862 case "WORKSTATION ID" :
863 if (value == null) {
864 _workstationID = DEF_WORKSTATIONID;
865 base.Remove (mappedKey);
866 } else
867 this.WorkstationID = value.ToString ();
868 break;
869 case "TRANSACTION BINDING":
870 // TODO: what is this?
871 break;
872 default :
873 throw new ArgumentException("Keyword not supported :" + key);
876 #endregion // Private Methods
881 #endif // NET_2_0