SqlConnectionStringBuilder.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. //
  2. // System.Data.SqlClient.SqlConnectionStringBuilder.cs
  3. //
  4. // Author:
  5. // Sureshkumar T ([email protected])
  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.
  27. //
  28. #if NET_2_0
  29. using System;
  30. using System.Text;
  31. using System.Collections;
  32. using System.Collections.Generic;
  33. using System.Data;
  34. using System.Data.Common;
  35. using System.ComponentModel;
  36. namespace System.Data.SqlClient
  37. {
  38. [DefaultPropertyAttribute ("DataSource")]
  39. public sealed class SqlConnectionStringBuilder : DbConnectionStringBuilder
  40. {
  41. private const string DEF_APPLICATIONNAME = ".NET SqlClient Data Provider";
  42. private const bool DEF_ASYNCHRONOUSPROCESSING = false;
  43. private const string DEF_ATTACHDBFILENAME = "";
  44. private const bool DEF_CONNECTIONRESET = true;
  45. private const int DEF_CONNECTTIMEOUT = 15;
  46. private const string DEF_CURRENTLANGUAGE = "";
  47. private const string DEF_DATASOURCE = "";
  48. private const bool DEF_ENCRYPT = false;
  49. private const bool DEF_ENLIST = false;
  50. private const string DEF_FAILOVERPARTNER = "";
  51. private const string DEF_INITIALCATALOG = "";
  52. private const bool DEF_INTEGRATEDSECURITY = false;
  53. private const int DEF_LOADBALANCETIMEOUT = 0;
  54. private const int DEF_MAXPOOLSIZE = 100;
  55. private const int DEF_MINPOOLSIZE = 0;
  56. private const bool DEF_MULTIPLEACTIVERESULTSETS = false;
  57. private const string DEF_NETWORKLIBRARY = "";
  58. private const int DEF_PACKETSIZE = 8000;
  59. private const string DEF_PASSWORD = "";
  60. private const bool DEF_PERSISTSECURITYINFO = false;
  61. private const bool DEF_POOLING = true;
  62. private const bool DEF_REPLICATION = false;
  63. private const string DEF_USERID = "";
  64. private const string DEF_WORKSTATIONID = "";
  65. private const string DEF_TYPESYSTEMVERSION = "Latest";
  66. private const bool DEF_TRUSTSERVERCERTIFICATE = false;
  67. private const bool DEF_USERINSTANCE = false;
  68. private const bool DEF_CONTEXTCONNECTION = false;
  69. #region // Fields
  70. private string _applicationName;
  71. private bool _asynchronousProcessing;
  72. private string _attachDBFilename;
  73. private bool _connectionReset;
  74. private int _connectTimeout;
  75. private string _currentLanguage;
  76. private string _dataSource;
  77. private bool _encrypt;
  78. private bool _enlist;
  79. private string _failoverPartner;
  80. private string _initialCatalog;
  81. private bool _integratedSecurity;
  82. private int _loadBalanceTimeout;
  83. private int _maxPoolSize;
  84. private int _minPoolSize;
  85. private bool _multipleActiveResultSets;
  86. private string _networkLibrary;
  87. private int _packetSize;
  88. private string _password;
  89. private bool _persistSecurityInfo;
  90. private bool _pooling;
  91. private bool _replication;
  92. private string _userID;
  93. private string _workstationID;
  94. private bool _trustServerCertificate;
  95. private string _typeSystemVersion;
  96. private bool _userInstance;
  97. private bool _contextConnection;
  98. private static Dictionary <string, string> _keywords; // for mapping duplicate keywords
  99. #endregion // Fields
  100. #region Constructors
  101. public SqlConnectionStringBuilder () : this (String.Empty)
  102. {
  103. }
  104. public SqlConnectionStringBuilder (string connectionString)
  105. {
  106. Init ();
  107. base.ConnectionString = connectionString;
  108. }
  109. static SqlConnectionStringBuilder ()
  110. {
  111. _keywords = new Dictionary <string, string> ();
  112. _keywords ["APP"] = "Application Name";
  113. _keywords ["APPLICATION NAME"] = "Application Name";
  114. _keywords ["ATTACHDBFILENAME"] = "AttachDBFilename";
  115. _keywords ["EXTENDED PROPERTIES"] = "Extended Properties";
  116. _keywords ["INITIAL FILE NAME"] = "Initial File Name";
  117. _keywords ["TIMEOUT"] = "Connect Timeout";
  118. _keywords ["CONNECT TIMEOUT"] = "Connect Timeout";
  119. _keywords ["CONNECTION TIMEOUT"] = "Connect Timeout";
  120. _keywords ["CONNECTION RESET"] = "Connection Reset";
  121. _keywords ["LANGUAGE"] = "Current Language";
  122. _keywords ["CURRENT LANGUAGE"] = "Current Language";
  123. _keywords ["DATA SOURCE"] = "Data Source";
  124. _keywords ["SERVER"] = "Data Source";
  125. _keywords ["ADDRESS"] = "Data Source";
  126. _keywords ["ADDR"] = "Data Source";
  127. _keywords ["NETWORK ADDRESS"] = "Data Source";
  128. _keywords ["ENCRYPT"] = "Encrypt";
  129. _keywords ["ENLIST"] = "Enlist";
  130. _keywords ["INITIAL CATALOG"] = "Initial Catalog";
  131. _keywords ["DATABASE"] = "Initial Catalog";
  132. _keywords ["INTEGRATED SECURITY"] = "Integrated Security";
  133. _keywords ["TRUSTED_CONNECTION"] = "Integrated Security";
  134. _keywords ["MAX POOL SIZE"] = "Max Pool Size";
  135. _keywords ["MIN POOL SIZE"] = "Min Pool Size";
  136. _keywords ["MULTIPLEACTIVERESULTSETS"] = "Multipleactiveresultset";
  137. _keywords ["ASYNCHRONOUS PROCESSING"] = "Asynchronous Processing";
  138. _keywords ["ASYNC"] = "Async";
  139. _keywords ["NET"] = "Network Library";
  140. _keywords ["NETWORK"] = "Network Library";
  141. _keywords ["NETWORK LIBRARY"] = "Network Library";
  142. _keywords ["PACKET SIZE"] = "Packet Size";
  143. _keywords ["PASSWORD"] = "Password";
  144. _keywords ["PWD"] = "Password";
  145. _keywords ["PERSISTSECURITYINFO"] = "Persist Security Info";
  146. _keywords ["PERSIST SECURITY INFO"] = "Persist Security Info";
  147. _keywords ["POOLING"] = "Pooling";
  148. _keywords ["UID"] = "User Id";
  149. _keywords ["USER"] = "User Id";
  150. _keywords ["USER ID"] = "User Id";
  151. _keywords ["WSID"] = "Workstation Id";
  152. _keywords ["WORKSTATION ID"] = "Workstation Id";
  153. _keywords ["USER INSTANCE"] = "User Instance";
  154. _keywords ["CONTEXT CONNECTION"] = "Context Connection";
  155. }
  156. #endregion // Constructors
  157. #region Properties
  158. [DisplayNameAttribute ("Application Name")]
  159. [RefreshPropertiesAttribute (RefreshProperties.All)]
  160. public string ApplicationName {
  161. get { return _applicationName; }
  162. set {
  163. base ["Application Name"] = value;
  164. _applicationName = value;
  165. }
  166. }
  167. [DisplayNameAttribute ("Asynchronous Processing")]
  168. [RefreshPropertiesAttribute (RefreshProperties.All)]
  169. public bool AsynchronousProcessing {
  170. get { return _asynchronousProcessing; }
  171. set {
  172. base ["Asynchronous Processing"] = value;
  173. _asynchronousProcessing = value;
  174. }
  175. }
  176. [EditorBrowsable (EditorBrowsableState.Never)]
  177. [DisplayNameAttribute ("AttachDbFilename")]
  178. [RefreshPropertiesAttribute (RefreshProperties.All)]
  179. public string AttachDBFilename {
  180. get { return _attachDBFilename; }
  181. set {
  182. base ["AttachDbFilename"] = value;
  183. _attachDBFilename = value;
  184. }
  185. }
  186. [DisplayNameAttribute ("Connection Reset")]
  187. [RefreshPropertiesAttribute (RefreshProperties.All)]
  188. public bool ConnectionReset {
  189. get { return _connectionReset; }
  190. set {
  191. base ["Connection Reset"] = value;
  192. _connectionReset = value;
  193. }
  194. }
  195. [DisplayNameAttribute ("Connect Timeout")]
  196. [RefreshPropertiesAttribute (RefreshProperties.All)]
  197. public int ConnectTimeout {
  198. get { return _connectTimeout; }
  199. set {
  200. base ["Connect Timeout"] = value;
  201. _connectTimeout = value;
  202. }
  203. }
  204. [DisplayNameAttribute ("Current Language")]
  205. [RefreshPropertiesAttribute (RefreshProperties.All)]
  206. public string CurrentLanguage {
  207. get { return _currentLanguage; }
  208. set {
  209. base ["Current Language"] = value;
  210. _currentLanguage = value;
  211. }
  212. }
  213. [DisplayNameAttribute ("Data Source")]
  214. [TypeConverterAttribute (typeof (string))]
  215. [RefreshPropertiesAttribute (RefreshProperties.All)]
  216. public string DataSource {
  217. get { return _dataSource; }
  218. set {
  219. base ["Data Source"] = value;
  220. _dataSource = value;
  221. }
  222. }
  223. [DisplayNameAttribute ("Encrypt")]
  224. [RefreshPropertiesAttribute (RefreshProperties.All)]
  225. public bool Encrypt {
  226. get { return _encrypt; }
  227. set {
  228. base ["Encrypt"] = value;
  229. _encrypt = value;
  230. }
  231. }
  232. [DisplayNameAttribute ("Enlist")]
  233. [RefreshPropertiesAttribute (RefreshProperties.All)]
  234. public bool Enlist {
  235. get { return _enlist; }
  236. set {
  237. base ["Enlist"] = value;
  238. _enlist = value;
  239. }
  240. }
  241. [DisplayNameAttribute ("Failover Partner")]
  242. [TypeConverterAttribute (typeof (string))]
  243. [RefreshPropertiesAttribute (RefreshProperties.All)]
  244. public string FailoverPartner {
  245. get { return _failoverPartner; }
  246. set {
  247. base ["Failover Partner"] = value;
  248. _failoverPartner = value;
  249. }
  250. }
  251. [DisplayNameAttribute ("Initial Catalog")]
  252. [TypeConverterAttribute (typeof (string))]
  253. [RefreshPropertiesAttribute (RefreshProperties.All)]
  254. public string InitialCatalog {
  255. get { return _initialCatalog; }
  256. set {
  257. base ["Initial Catalog"] = value;
  258. _initialCatalog = value;
  259. }
  260. }
  261. [DisplayNameAttribute ("Integrated Security")]
  262. [RefreshPropertiesAttribute (RefreshProperties.All)]
  263. public bool IntegratedSecurity {
  264. get { return _integratedSecurity; }
  265. set {
  266. base ["Integrated Security"] = value;
  267. _integratedSecurity = value;
  268. }
  269. }
  270. public override bool IsFixedSize {
  271. get { return true; }
  272. }
  273. public override object this [string keyword] {
  274. get {
  275. string mapped = MapKeyword (keyword);
  276. return base [mapped];
  277. }
  278. set {SetValue (keyword, value);}
  279. }
  280. public override ICollection Keys {
  281. get { return base.Keys; }
  282. }
  283. [DisplayNameAttribute ("Load Balance Timeout")]
  284. [RefreshPropertiesAttribute (RefreshProperties.All)]
  285. public int LoadBalanceTimeout {
  286. get { return _loadBalanceTimeout; }
  287. set {
  288. base ["Load Balance Timeout"] = value;
  289. _loadBalanceTimeout = value;
  290. }
  291. }
  292. [DisplayNameAttribute ("Max Pool Size")]
  293. [RefreshPropertiesAttribute (RefreshProperties.All)]
  294. public int MaxPoolSize {
  295. get { return _maxPoolSize; }
  296. set {
  297. base ["Max Pool Size"] = value;
  298. _maxPoolSize = value;
  299. }
  300. }
  301. [DisplayNameAttribute ("Min Pool Size")]
  302. [RefreshPropertiesAttribute (RefreshProperties.All)]
  303. public int MinPoolSize {
  304. get { return _minPoolSize; }
  305. set {
  306. base ["Min Pool Size"] = value;
  307. _minPoolSize = value;
  308. }
  309. }
  310. [DisplayNameAttribute ("MultipleActiveResultSets")]
  311. [RefreshPropertiesAttribute (RefreshProperties.All)]
  312. public bool MultipleActiveResultSets {
  313. get { return _multipleActiveResultSets; }
  314. set {
  315. base ["Multiple Active Resultsets"] = value;
  316. _multipleActiveResultSets = value;
  317. }
  318. }
  319. [DisplayNameAttribute ("Network Library")]
  320. [TypeConverterAttribute (typeof (string))]
  321. [RefreshPropertiesAttribute (RefreshProperties.All)]
  322. public string NetworkLibrary {
  323. get { return _networkLibrary; }
  324. set {
  325. base ["Network Library"] = value;
  326. _networkLibrary = value;
  327. }
  328. }
  329. [DisplayNameAttribute ("Packet Size")]
  330. [RefreshPropertiesAttribute (RefreshProperties.All)]
  331. public int PacketSize {
  332. get { return _packetSize; }
  333. set {
  334. base ["Packet Size"] = value;
  335. _packetSize = value;
  336. }
  337. }
  338. [DisplayNameAttribute ("Password")]
  339. [PasswordPropertyTextAttribute (true)]
  340. [RefreshPropertiesAttribute (RefreshProperties.All)]
  341. public string Password {
  342. get { return _password; }
  343. set {
  344. base ["Password"] = value;
  345. _password = value;
  346. }
  347. }
  348. [DisplayNameAttribute ("Persist Security Info")]
  349. [RefreshPropertiesAttribute (RefreshProperties.All)]
  350. public bool PersistSecurityInfo {
  351. get { return _persistSecurityInfo; }
  352. set {
  353. base ["Persist Security Info"] = value;
  354. _persistSecurityInfo = value;
  355. }
  356. }
  357. [DisplayNameAttribute ("Pooling")]
  358. [RefreshPropertiesAttribute (RefreshProperties.All)]
  359. public bool Pooling {
  360. get { return _pooling; }
  361. set {
  362. base ["Pooling"] = value;
  363. _pooling = value;
  364. }
  365. }
  366. [DisplayNameAttribute ("Replication")]
  367. [RefreshPropertiesAttribute (RefreshProperties.All)]
  368. public bool Replication {
  369. get { return _replication; }
  370. set {
  371. base ["Replication"] = value;
  372. _replication = value;
  373. }
  374. }
  375. [DisplayNameAttribute ("User ID")]
  376. [RefreshPropertiesAttribute (RefreshProperties.All)]
  377. public string UserID {
  378. get { return _userID; }
  379. set {
  380. base ["User Id"]= value;
  381. _userID = value;
  382. }
  383. }
  384. public override ICollection Values {
  385. get { return base.Values; }
  386. }
  387. [DisplayNameAttribute ("Workstation ID")]
  388. [RefreshPropertiesAttribute (RefreshProperties.All)]
  389. public string WorkstationID {
  390. get { return _workstationID; }
  391. set {
  392. base ["Workstation Id"] = value;
  393. _workstationID = value;
  394. }
  395. }
  396. [DisplayNameAttribute ("TrustServerCertificate")]
  397. [RefreshProperties (RefreshProperties.All)]
  398. public bool TrustServerCertificate {
  399. get { return _trustServerCertificate; }
  400. set {
  401. base ["Trust Server Certificate"] = value;
  402. _trustServerCertificate = value;
  403. }
  404. }
  405. [DisplayNameAttribute ("Type System Version")]
  406. [RefreshProperties (RefreshProperties.All)]
  407. public string TypeSystemVersion {
  408. get { return _typeSystemVersion; }
  409. set {
  410. base ["Type System Version"] = value;
  411. _typeSystemVersion = value;
  412. }
  413. }
  414. [DisplayNameAttribute ("User Instance")]
  415. [RefreshProperties (RefreshProperties.All)]
  416. public bool UserInstance {
  417. get { return _userInstance; }
  418. set {
  419. base ["User Instance"] = value;
  420. _userInstance = value;
  421. }
  422. }
  423. [RefreshPropertiesAttribute (RefreshProperties.All)]
  424. [DisplayNameAttribute ("Context Connection")]
  425. public bool ContextConnection {
  426. get { return _contextConnection; }
  427. set {
  428. base ["Context Connection"] = value;
  429. _contextConnection = value;
  430. }
  431. }
  432. #endregion // Properties
  433. #region Methods
  434. private void Init ()
  435. {
  436. _applicationName = DEF_APPLICATIONNAME;
  437. _asynchronousProcessing = DEF_ASYNCHRONOUSPROCESSING;
  438. _attachDBFilename = DEF_ATTACHDBFILENAME;
  439. _connectionReset = DEF_CONNECTIONRESET;
  440. _connectTimeout = DEF_CONNECTTIMEOUT;
  441. _currentLanguage = DEF_CURRENTLANGUAGE;
  442. _dataSource = DEF_DATASOURCE;
  443. _encrypt = DEF_ENCRYPT;
  444. _enlist = DEF_ENLIST;
  445. _failoverPartner = DEF_FAILOVERPARTNER;
  446. _initialCatalog = DEF_INITIALCATALOG;
  447. _integratedSecurity = DEF_INTEGRATEDSECURITY;
  448. _loadBalanceTimeout = DEF_LOADBALANCETIMEOUT;
  449. _maxPoolSize = DEF_MAXPOOLSIZE;
  450. _minPoolSize = DEF_MINPOOLSIZE;
  451. _multipleActiveResultSets= DEF_MULTIPLEACTIVERESULTSETS;
  452. _networkLibrary = DEF_NETWORKLIBRARY;
  453. _packetSize = DEF_PACKETSIZE;
  454. _password = DEF_PASSWORD;
  455. _persistSecurityInfo = DEF_PERSISTSECURITYINFO;
  456. _pooling = DEF_POOLING;
  457. _replication = DEF_REPLICATION;
  458. _userID = DEF_USERID;
  459. _workstationID = DEF_WORKSTATIONID;
  460. _trustServerCertificate = DEF_TRUSTSERVERCERTIFICATE;
  461. _typeSystemVersion = DEF_TYPESYSTEMVERSION;
  462. _userInstance = DEF_USERINSTANCE;
  463. _contextConnection = DEF_CONTEXTCONNECTION;
  464. }
  465. public override void Clear ()
  466. {
  467. base.Clear ();
  468. Init ();
  469. }
  470. public override bool ContainsKey (string keyword)
  471. {
  472. keyword = keyword.ToUpper ().Trim ();
  473. if (_keywords.ContainsKey (keyword))
  474. return base.ContainsKey (_keywords [keyword]);
  475. return false;
  476. }
  477. public override bool Remove (string keyword)
  478. {
  479. if (!ContainsKey (keyword))
  480. return false;
  481. this [keyword] = null;
  482. return true;
  483. }
  484. [MonoNotSupported ("")] // Note that base.ShouldSerialize() is called but not implemented
  485. public override bool ShouldSerialize (string keyword)
  486. {
  487. if (!ContainsKey (keyword))
  488. return false;
  489. keyword = keyword.ToUpper ().Trim ();
  490. // Assuming passwords cannot be serialized.
  491. if (_keywords [keyword] == "Password")
  492. return false;
  493. return base.ShouldSerialize (_keywords [keyword]);
  494. }
  495. public override bool TryGetValue (string keyword, out object value)
  496. {
  497. if (! ContainsKey (keyword)) {
  498. value = String.Empty;
  499. return false;
  500. }
  501. return base.TryGetValue (_keywords [keyword.ToUpper ().Trim ()], out value);
  502. }
  503. #endregion // Methods
  504. #region Private Methods
  505. private string MapKeyword (string keyword)
  506. {
  507. keyword = keyword.ToUpper ().Trim ();
  508. if (! _keywords.ContainsKey (keyword))
  509. throw new ArgumentException("Keyword not supported :" + keyword);
  510. return _keywords [keyword];
  511. }
  512. private void SetValue (string key, object value)
  513. {
  514. if (key == null)
  515. throw new ArgumentNullException ("key cannot be null!");
  516. string mappedKey = MapKeyword (key);
  517. switch (mappedKey.ToUpper ().Trim ()) {
  518. case "APPLICATION NAME" :
  519. if (value == null) {
  520. _applicationName = DEF_APPLICATIONNAME;
  521. base.Remove (mappedKey);
  522. } else
  523. this.ApplicationName = value.ToString ();
  524. break;
  525. case "ATTACHDBFILENAME" :
  526. throw new NotImplementedException ("Attachable database support is " +
  527. "not implemented.");
  528. case "CONNECT TIMEOUT" :
  529. if (value == null) {
  530. _connectTimeout = DEF_CONNECTTIMEOUT;
  531. base.Remove (mappedKey);
  532. } else
  533. this.ConnectTimeout = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
  534. break;
  535. case "CONNECTION LIFETIME" :
  536. break;
  537. case "CONNECTION RESET" :
  538. if (value == null) {
  539. _connectionReset = DEF_CONNECTIONRESET;
  540. base.Remove (mappedKey);
  541. } else
  542. this.ConnectionReset = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
  543. break;
  544. case "CURRENT LANGUAGE" :
  545. if (value == null) {
  546. _currentLanguage = DEF_CURRENTLANGUAGE;
  547. base.Remove (mappedKey);
  548. } else
  549. this.CurrentLanguage = value.ToString ();
  550. break;
  551. case "CONTEXT CONNECTION" :
  552. if (value == null) {
  553. _contextConnection = DEF_CONTEXTCONNECTION;
  554. base.Remove (mappedKey);
  555. } else
  556. this.ContextConnection = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
  557. break;
  558. case "DATA SOURCE" :
  559. if (value == null) {
  560. _dataSource = DEF_DATASOURCE;
  561. base.Remove (mappedKey);
  562. } else
  563. this.DataSource = value.ToString ();
  564. break;
  565. case "ENCRYPT":
  566. if (value == null) {
  567. _encrypt = DEF_ENCRYPT;
  568. base.Remove (mappedKey);
  569. }else if (DbConnectionStringBuilderHelper.ConvertToBoolean(value))
  570. throw new NotImplementedException("SSL encryption for"
  571. + " data sent between client and server is not"
  572. + " implemented.");
  573. break;
  574. case "ENLIST" :
  575. if (value == null) {
  576. _enlist = DEF_ENLIST;
  577. base.Remove (mappedKey);
  578. } else if ( ! DbConnectionStringBuilderHelper.ConvertToBoolean(value))
  579. throw new NotImplementedException("Disabling the automatic"
  580. + " enlistment of connections in the thread's current"
  581. + " transaction context is not implemented.");
  582. break;
  583. case "INITIAL CATALOG" :
  584. if (value == null) {
  585. _initialCatalog = DEF_INITIALCATALOG;
  586. base.Remove (mappedKey);
  587. } else
  588. this.InitialCatalog = value.ToString ();
  589. break;
  590. case "INTEGRATED SECURITY" :
  591. if (value == null) {
  592. _integratedSecurity = DEF_INTEGRATEDSECURITY;
  593. base.Remove (mappedKey);
  594. } else
  595. this.IntegratedSecurity = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
  596. break;
  597. case "MAX POOL SIZE" :
  598. if (value == null) {
  599. _maxPoolSize = DEF_MAXPOOLSIZE;
  600. base.Remove (mappedKey);
  601. } else
  602. this.MaxPoolSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
  603. break;
  604. case "MIN POOL SIZE" :
  605. if (value == null) {
  606. _minPoolSize = DEF_MINPOOLSIZE;
  607. base.Remove (mappedKey);
  608. } else
  609. this.MinPoolSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
  610. break;
  611. case "MULTIPLEACTIVERESULTSETS":
  612. if (value == null) {
  613. _multipleActiveResultSets = DEF_MULTIPLEACTIVERESULTSETS;
  614. base.Remove (mappedKey);
  615. } else if ( DbConnectionStringBuilderHelper.ConvertToBoolean (value))
  616. throw new NotImplementedException ("MARS is not yet implemented!");
  617. break;
  618. case "ASYNCHRONOUS PROCESSING" :
  619. if (value == null) {
  620. _asynchronousProcessing = DEF_ASYNCHRONOUSPROCESSING;
  621. base.Remove (mappedKey);
  622. } else
  623. this.AsynchronousProcessing = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
  624. break;
  625. case "NETWORK LIBRARY" :
  626. if (value == null) {
  627. _networkLibrary = DEF_NETWORKLIBRARY;
  628. base.Remove (mappedKey);
  629. } else {
  630. if (!value.ToString ().ToUpper ().Equals ("DBMSSOCN"))
  631. throw new ArgumentException ("Unsupported network library.");
  632. this.NetworkLibrary = value.ToString ().ToLower ();
  633. }
  634. break;
  635. case "PACKET SIZE" :
  636. if (value == null) {
  637. _packetSize = DEF_PACKETSIZE;
  638. base.Remove (mappedKey);
  639. } else
  640. this.PacketSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
  641. break;
  642. case "PASSWORD" :
  643. if (value == null) {
  644. _password = DEF_PASSWORD;
  645. base.Remove (mappedKey);
  646. } else
  647. this.Password = value.ToString ();
  648. break;
  649. case "PERSIST SECURITY INFO" :
  650. if (value == null) {
  651. _persistSecurityInfo = DEF_PERSISTSECURITYINFO;
  652. base.Remove (mappedKey);
  653. } else if (DbConnectionStringBuilderHelper.ConvertToBoolean (value))
  654. throw new NotImplementedException ("Persisting security info" +
  655. " is not yet implemented");
  656. break;
  657. case "POOLING" :
  658. if (value == null) {
  659. _pooling = DEF_POOLING;
  660. base.Remove (mappedKey);
  661. } else
  662. this.Pooling = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
  663. break;
  664. case "USER ID" :
  665. if (value == null) {
  666. _userID = DEF_USERID;
  667. base.Remove (mappedKey);
  668. } else
  669. this.UserID = value.ToString ();
  670. break;
  671. case "USER INSTANCE" :
  672. if (value == null) {
  673. _userInstance = DEF_USERINSTANCE;
  674. base.Remove (mappedKey);
  675. } else
  676. this.UserInstance = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
  677. break;
  678. case "WORKSTATION ID" :
  679. if (value == null) {
  680. _workstationID = DEF_WORKSTATIONID;
  681. base.Remove (mappedKey);
  682. } else
  683. this.WorkstationID = value.ToString ();
  684. break;
  685. default :
  686. throw new ArgumentException("Keyword not supported :" + key);
  687. }
  688. }
  689. #endregion // Private Methods
  690. }
  691. }
  692. #endif // NET_2_0