mono /mcs/class/System.Data/System.Data.SqlClient/SqlConnectionStringBuilder.cs

Language C# Lines 882
MD5 Hash 1852b4e7a687d566020dd21d3941139d Estimated Cost $21,234 (why?)
Repository https://bitbucket.org/danipen/mono.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
//
// System.Data.SqlClient.SqlConnectionStringBuilder.cs
//
// Author:
//   Sureshkumar T (tsureshkumar@novell.com)
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#if NET_2_0
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;

using System.Data;
using System.Data.Common;
using System.ComponentModel;

namespace System.Data.SqlClient
{
	[DefaultPropertyAttribute ("DataSource")]
#if NET_2_0
	[TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlConnectionStringBuilderConverter, " + Consts.AssemblySystem_Data)]
#endif
	public sealed class SqlConnectionStringBuilder : DbConnectionStringBuilder
	{

		private const string 	DEF_APPLICATIONNAME 		= ".NET SqlClient Data Provider";
		private const bool 	DEF_ASYNCHRONOUSPROCESSING 	= false;
		private const string 	DEF_ATTACHDBFILENAME 		= "";
		private const bool 	DEF_CONNECTIONRESET 		= true;
		private const int 	DEF_CONNECTTIMEOUT 		= 15;
		private const string 	DEF_CURRENTLANGUAGE 		= "";
		private const string 	DEF_DATASOURCE 			= "";
		private const bool 	DEF_ENCRYPT 			= false;
		private const bool 	DEF_ENLIST 			= false;
		private const string 	DEF_FAILOVERPARTNER 		= "";
		private const string 	DEF_INITIALCATALOG 		= "";
		private const bool 	DEF_INTEGRATEDSECURITY 		= false;
		private const int 	DEF_LOADBALANCETIMEOUT 		= 0;
		private const int 	DEF_MAXPOOLSIZE 		= 100;
		private const int 	DEF_MINPOOLSIZE 		= 0;
		private const bool 	DEF_MULTIPLEACTIVERESULTSETS 	= false;
		private const string 	DEF_NETWORKLIBRARY 		= "";
		private const int 	DEF_PACKETSIZE 			= 8000;
		private const string 	DEF_PASSWORD 			= "";
		private const bool 	DEF_PERSISTSECURITYINFO		= false;
		private const bool 	DEF_POOLING 			= true;
		private const bool 	DEF_REPLICATION 		= false;
		private const string 	DEF_USERID 			= "";
		private const string 	DEF_WORKSTATIONID 		= "";
		private const string 	DEF_TYPESYSTEMVERSION 		= "Latest";
		private const bool	DEF_TRUSTSERVERCERTIFICATE	= false;
		private const bool	DEF_USERINSTANCE		= false;  
		private const bool	DEF_CONTEXTCONNECTION		= false;	
		private const string	DEF_TRANSACTIONBINDING		= "Implicit Unbind";


		#region // Fields
 		private string 	_applicationName;
		private bool 	_asynchronousProcessing;
		private string 	_attachDBFilename;
		private bool 	_connectionReset;
		private int 	_connectTimeout;
		private string 	_currentLanguage;
		private string 	_dataSource;
		private bool 	_encrypt;
		private bool 	_enlist;
		private string 	_failoverPartner;
		private string 	_initialCatalog;
		private bool 	_integratedSecurity;
		private int 	_loadBalanceTimeout;
		private int 	_maxPoolSize;
		private int 	_minPoolSize;
		private bool 	_multipleActiveResultSets;
		private string 	_networkLibrary;
		private int 	_packetSize;
		private string 	_password;
		private bool 	_persistSecurityInfo;
		private bool 	_pooling;
		private bool 	_replication;
		private string 	_userID;
		private string 	_workstationID;
		private bool	_trustServerCertificate;
		private string	_typeSystemVersion;
		private bool	_userInstance;
		private bool	_contextConnection;
		private string	_transactionBinding;

		private static Dictionary <string, string> _keywords; // for mapping duplicate keywords
		private static Dictionary <string, object> _defaults; 
		#endregion // Fields

		#region Constructors
		public SqlConnectionStringBuilder () : this (String.Empty)
		{
		}

		public SqlConnectionStringBuilder (string connectionString)
		{
			Init ();
			base.ConnectionString = connectionString;
		}

		static SqlConnectionStringBuilder ()
		{
			_keywords = new Dictionary <string, string> ();
			_keywords ["APP"] 			= "Application Name";
			_keywords ["APPLICATION NAME"] 		= "Application Name";
			_keywords ["ATTACHDBFILENAME"] 		= "AttachDbFilename";
			_keywords ["EXTENDED PROPERTIES"] 	= "Extended Properties";
			_keywords ["INITIAL FILE NAME"]		= "Initial File Name";
			_keywords ["TIMEOUT"] 			= "Connect Timeout";
			_keywords ["CONNECT TIMEOUT"] 		= "Connect Timeout";
			_keywords ["CONNECTION TIMEOUT"]	= "Connect Timeout";
			_keywords ["CONNECTION RESET"] 		= "Connection Reset";
			_keywords ["LANGUAGE"] 			= "Current Language";
			_keywords ["CURRENT LANGUAGE"] 		= "Current Language";
			_keywords ["DATA SOURCE"] 		= "Data Source";
			_keywords ["SERVER"] 			= "Data Source";
			_keywords ["ADDRESS"] 			= "Data Source";
			_keywords ["ADDR"] 			= "Data Source";
			_keywords ["NETWORK ADDRESS"] 		= "Data Source";
			_keywords ["ENCRYPT"] 			= "Encrypt";
			_keywords ["ENLIST"] 			= "Enlist";
			_keywords ["INITIAL CATALOG"] 		= "Initial Catalog";
			_keywords ["DATABASE"] 			= "Initial Catalog";
			_keywords ["INTEGRATED SECURITY"]	= "Integrated Security";
			_keywords ["TRUSTED_CONNECTION"] 	= "Integrated Security";
			_keywords ["MAX POOL SIZE"] 		= "Max Pool Size";
			_keywords ["MIN POOL SIZE"] 		= "Min Pool Size";
			_keywords ["MULTIPLEACTIVERESULTSETS"] 	= "MultipleActiveResultSets";
			_keywords ["ASYNCHRONOUS PROCESSING"] 	= "Asynchronous Processing";
			_keywords ["ASYNC"] 			= "Async";
			_keywords ["NET"] 			= "Network Library";
			_keywords ["NETWORK"] 			= "Network Library";
			_keywords ["NETWORK LIBRARY"] 		= "Network Library";
			_keywords ["PACKET SIZE"] 		= "Packet Size";
			_keywords ["PASSWORD"] 			= "Password";
			_keywords ["PWD"] 			= "Password";
			_keywords ["PERSISTSECURITYINFO"]	= "Persist Security Info";
			_keywords ["PERSIST SECURITY INFO"] 	= "Persist Security Info";
			_keywords ["POOLING"] 			= "Pooling";
			_keywords ["UID"] 			= "User ID";
			_keywords ["USER"] 			= "User ID";
			_keywords ["USER ID"] 			= "User ID";
			_keywords ["WSID"] 			= "Workstation ID";
			_keywords ["WORKSTATION ID"]		= "Workstation ID";
			_keywords ["USER INSTANCE"]		= "User Instance";
			_keywords ["CONTEXT CONNECTION"]	= "Context Connection";
			_keywords ["TRANSACTION BINDING"]	= "Transaction Binding";
			_keywords ["FAILOVER PARTNER"]		= "Failover Partner";
			_keywords ["REPLICATION"]		= "Replication";
			_keywords ["TRUSTSERVERCERTIFICATE"]	= "TrustServerCertificate";
			_keywords ["LOAD BALANCE TIMEOUT"]	= "Load Balance Timeout";
			_keywords ["TYPE SYSTEM VERSION"]	= "Type System Version";

			_defaults = new Dictionary<string, object> ();
			_defaults.Add("Data Source", DEF_DATASOURCE);
			_defaults.Add("Failover Partner", DEF_FAILOVERPARTNER);
			_defaults.Add("AttachDbFilename", DEF_ATTACHDBFILENAME);
			_defaults.Add("Initial Catalog", DEF_INITIALCATALOG);
			_defaults.Add("Integrated Security", DEF_INTEGRATEDSECURITY);
			_defaults.Add("Persist Security Info", DEF_PERSISTSECURITYINFO);
			_defaults.Add("User ID", DEF_USERID);
			_defaults.Add("Password", DEF_PASSWORD);
			_defaults.Add("Enlist", DEF_ENLIST);
			_defaults.Add("Pooling", DEF_POOLING);
			_defaults.Add("Min Pool Size", DEF_MINPOOLSIZE);
			_defaults.Add("Max Pool Size", DEF_MAXPOOLSIZE);
			_defaults.Add("Asynchronous Processing", DEF_ASYNCHRONOUSPROCESSING);
			_defaults.Add("Connection Reset", DEF_CONNECTIONRESET);
			_defaults.Add("MultipleActiveResultSets", DEF_MULTIPLEACTIVERESULTSETS);
			_defaults.Add("Replication", DEF_REPLICATION);
			_defaults.Add("Connect Timeout", DEF_CONNECTTIMEOUT);
			_defaults.Add("Encrypt", DEF_ENCRYPT);
			_defaults.Add("TrustServerCertificate", DEF_TRUSTSERVERCERTIFICATE);
			_defaults.Add("Load Balance Timeout", DEF_LOADBALANCETIMEOUT);
			_defaults.Add("Network Library", DEF_NETWORKLIBRARY);
			_defaults.Add("Packet Size", DEF_PACKETSIZE);
			_defaults.Add("Type System Version", DEF_TYPESYSTEMVERSION);
			_defaults.Add("Application Name", DEF_APPLICATIONNAME);
			_defaults.Add("Current Language", DEF_CURRENTLANGUAGE);
			_defaults.Add("Workstation ID", DEF_WORKSTATIONID);
			_defaults.Add("User Instance", DEF_USERINSTANCE);
			_defaults.Add("Context Connection", DEF_CONTEXTCONNECTION);
			_defaults.Add("Transaction Binding", DEF_TRANSACTIONBINDING);			
		}
		#endregion // Constructors

		#region Properties
		[DisplayNameAttribute ("Application Name")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public string ApplicationName { 
			get { return _applicationName; }
			set { 
				base ["Application Name"] = value;
				_applicationName = value; 
			}
		}

		[DisplayNameAttribute ("Asynchronous Processing")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public bool AsynchronousProcessing { 
			get { return _asynchronousProcessing; }
			set { 
				base ["Asynchronous Processing"] = value;
				_asynchronousProcessing = value; 
			}
		}

#if NET_2_0
		[Editor ("System.Windows.Forms.Design.FileNameEditor, " + Consts.AssemblySystem_Design,
			 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
#else
		[Editor ("Microsoft.VSDesigner.Data.Design.DBParametersEditor, " + Consts.AssemblyMicrosoft_VSDesigner,
			 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
#endif
		[DisplayNameAttribute ("AttachDbFilename")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public string AttachDBFilename { 
			get { return _attachDBFilename; }
			set { 
				base ["AttachDbFilename"] = value;
				_attachDBFilename = value; 
			}
		}
		
		[DisplayNameAttribute ("Connection Reset")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public bool ConnectionReset { 
			get { return _connectionReset; }
			set { 
				base ["Connection Reset"] = value;
				_connectionReset = value; 
			}
		}
		
		[DisplayNameAttribute ("Connect Timeout")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public int ConnectTimeout { 
			get { return _connectTimeout; }
			set { 
				base ["Connect Timeout"] = value;
				_connectTimeout = value; 
			}
		}

		[DisplayNameAttribute ("Current Language")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public string CurrentLanguage { 
			get { return _currentLanguage; }
			set { 
				base ["Current Language"] = value;
				_currentLanguage = value; 
			}
		}

		[DisplayNameAttribute ("Data Source")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
#if NET_2_0
		[TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlDataSourceConverter, " + Consts.AssemblySystem_Data)]
#endif
		public string DataSource { 
			get { return _dataSource; }
			set { 
				base ["Data Source"] = value;
				_dataSource = value; 
			}
		}

		[DisplayNameAttribute ("Encrypt")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public bool Encrypt { 
			get { return _encrypt; }
			set { 
				base ["Encrypt"] = value;
				_encrypt = value; 
			}
		}

		[DisplayNameAttribute ("Enlist")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public bool Enlist { 
			get { return _enlist; }
			set { 
				base ["Enlist"] = value;
				_enlist = value; 
			}
		}

		[DisplayNameAttribute ("Failover Partner")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
#if NET_2_0
		[TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlDataSourceConverter, " + Consts.AssemblySystem_Data)]
#endif
		public string FailoverPartner { 
			get { return _failoverPartner; }
			set { 
				base ["Failover Partner"] = value;
				_failoverPartner = value; 
			}
		}

		[DisplayNameAttribute ("Initial Catalog")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
#if NET_2_0
		[TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+SqlInitialCatalogConverter, " + Consts.AssemblySystem_Data)]
#endif
		public string InitialCatalog { 
			get { return _initialCatalog; }
			set { 
				base ["Initial Catalog"] = value;
				_initialCatalog = value; 
			}
		}

		[DisplayNameAttribute ("Integrated Security")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public bool IntegratedSecurity { 
			get { return _integratedSecurity; }
			set { 
				base ["Integrated Security"] = value;
				_integratedSecurity = value; 
			}
		}

		public override bool IsFixedSize { 
			get { return true; }
		}

		public override object this [string keyword] { 
			get { 
				string mapped = MapKeyword (keyword);
				if (base.ContainsKey (mapped)) 
					return base [mapped];
				else
					return _defaults [mapped];
			}
			set {SetValue (keyword, value);}
		}

		public override ICollection Keys { 
			get { 
				List<string> keys = new List<string>();
                                keys.Add("Data Source");
                                keys.Add("Failover Partner");
                                keys.Add("AttachDbFilename");
                                keys.Add("Initial Catalog");
                                keys.Add("Integrated Security");
                                keys.Add("Persist Security Info");
                                keys.Add("User ID");
                                keys.Add("Password");
                                keys.Add("Enlist");
                                keys.Add("Pooling");
                                keys.Add("Min Pool Size");
                                keys.Add("Max Pool Size");
                                keys.Add("Asynchronous Processing");
                                keys.Add("Connection Reset");
                                keys.Add("MultipleActiveResultSets");
                                keys.Add("Replication");
                                keys.Add("Connect Timeout");
                                keys.Add("Encrypt");
                                keys.Add("TrustServerCertificate");
                                keys.Add("Load Balance Timeout");
                                keys.Add("Network Library");
                                keys.Add("Packet Size");
                                keys.Add("Type System Version");
                                keys.Add("Application Name");
                                keys.Add("Current Language");
                                keys.Add("Workstation ID");
                                keys.Add("User Instance");
                                keys.Add("Context Connection");
                                keys.Add("Transaction Binding");
				ReadOnlyCollection<string> coll = new ReadOnlyCollection<string>(keys);
				return coll;
			}
		}

		[DisplayNameAttribute ("Load Balance Timeout")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public int LoadBalanceTimeout { 
			get { return _loadBalanceTimeout; }
			set { 
				base ["Load Balance Timeout"] = value;
				_loadBalanceTimeout = value; 
			}
		}

		[DisplayNameAttribute ("Max Pool Size")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public int MaxPoolSize { 
			get { return _maxPoolSize; }
			set { 
				base ["Max Pool Size"] = value;
				_maxPoolSize = value; 
			}
		}

		[DisplayNameAttribute ("Min Pool Size")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public int MinPoolSize { 
			get { return _minPoolSize; }
			set {
				base ["Min Pool Size"] = value;
				_minPoolSize = value; 
			}
		}

		[DisplayNameAttribute ("MultipleActiveResultSets")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public bool MultipleActiveResultSets { 
			get { return _multipleActiveResultSets; }
			set { 
				base ["Multiple Active Resultsets"] = value;
				_multipleActiveResultSets = value; 
			}
		}

		[DisplayNameAttribute ("Network Library")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
#if NET_2_0
		[TypeConverterAttribute ("System.Data.SqlClient.SqlConnectionStringBuilder+NetworkLibraryConverter, " + Consts.AssemblySystem_Data)]
#endif
		public string NetworkLibrary { 
			get { return _networkLibrary; }
			set { 
				base ["Network Library"] = value;
				_networkLibrary = value; 
			}
		}

		[DisplayNameAttribute ("Packet Size")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public int PacketSize { 
			get { return _packetSize; }
			set { 
				base ["Packet Size"] = value;
				_packetSize = value; 
			}
		}

		[DisplayNameAttribute ("Password")]
		[PasswordPropertyTextAttribute (true)]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public string Password { 
			get { return _password; }
			set { 
				base ["Password"] = value;
				_password = value; 
			}
		}

		[DisplayNameAttribute ("Persist Security Info")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public bool PersistSecurityInfo { 
			get { return _persistSecurityInfo; }
			set {
				base ["Persist Security Info"] = value;
				_persistSecurityInfo = value; 
			}
		}
		
		[DisplayNameAttribute ("Pooling")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public bool Pooling { 
			get { return _pooling; }
			set {
				base ["Pooling"] = value;
				_pooling = value; 
			}
		}

		[DisplayNameAttribute ("Replication")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public bool Replication { 
			get { return _replication; }
			set { 
				base ["Replication"] = value;
				_replication = value; 
			}
		}

		[DisplayNameAttribute ("User ID")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public string UserID { 
			get { return _userID; }
			set { 
				base ["User Id"]= value;
				_userID = value; 
			}
		}
		
		public override ICollection Values { 
			get {
				List<object> values = new List<object>();
                                values.Add(_dataSource);
                                values.Add(_failoverPartner);
                                values.Add(_attachDBFilename);
                                values.Add(_initialCatalog);
                                values.Add(_integratedSecurity);
                                values.Add(_persistSecurityInfo);
                                values.Add(_userID);
                                values.Add(_password);
                                values.Add(_enlist);
                                values.Add(_pooling);
                                values.Add(_minPoolSize);
                                values.Add(_maxPoolSize);
                                values.Add(_asynchronousProcessing);
                                values.Add(_connectionReset);
                                values.Add(_multipleActiveResultSets);
                                values.Add(_replication);
                                values.Add(_connectTimeout);
                                values.Add(_encrypt);
                                values.Add(_trustServerCertificate);
                                values.Add(_loadBalanceTimeout);
                                values.Add(_networkLibrary);
                                values.Add(_packetSize);
                                values.Add(_typeSystemVersion);
                                values.Add(_applicationName);
                                values.Add(_currentLanguage);
                                values.Add(_workstationID);
                                values.Add(_userInstance);
                                values.Add(_contextConnection);
                                values.Add(_transactionBinding);
				ReadOnlyCollection<object> coll = new ReadOnlyCollection<object>(values);
				return coll;		 
			}
		}

		[DisplayNameAttribute ("Workstation ID")]
		[RefreshPropertiesAttribute (RefreshProperties.All)]
		public string WorkstationID { 
			get { return _workstationID; }
			set { 
				base ["Workstation Id"] = value;
				_workstationID = value; 
			}
		}

		[DisplayNameAttribute ("TrustServerCertificate")]
		[RefreshProperties (RefreshProperties.All)]
		public bool TrustServerCertificate { 
			get { return _trustServerCertificate; } 
			set {
				base ["Trust Server Certificate"] = value;
				 _trustServerCertificate = value;
			}
		}

		[DisplayNameAttribute ("Type System Version")]
		[RefreshProperties (RefreshProperties.All)]
		public string TypeSystemVersion { 
			get { return _typeSystemVersion; } 
			set {
				base ["Type System Version"] = value;				
				_typeSystemVersion = value; 
			}
		}

		[DisplayNameAttribute ("User Instance")]
		[RefreshProperties (RefreshProperties.All)]
		public bool UserInstance { 
			get { return _userInstance; }
			set { 
				base ["User Instance"] = value;
				_userInstance = value;
			}
		}

		[RefreshPropertiesAttribute (RefreshProperties.All)]
		[DisplayNameAttribute ("Context Connection")]
		public bool ContextConnection { 
			get { return _contextConnection; }
			set { 
				base ["Context Connection"] = value;
				_contextConnection = value;
			}
		}
		#endregion // Properties

		#region Methods
		private void Init ()
		{
			_applicationName 	= DEF_APPLICATIONNAME;
			_asynchronousProcessing	= DEF_ASYNCHRONOUSPROCESSING;
			_attachDBFilename	= DEF_ATTACHDBFILENAME;
			_connectionReset	= DEF_CONNECTIONRESET;
			_connectTimeout		= DEF_CONNECTTIMEOUT;
			_currentLanguage	= DEF_CURRENTLANGUAGE;
			_dataSource		= DEF_DATASOURCE;
			_encrypt		= DEF_ENCRYPT;
			_enlist			= DEF_ENLIST;
			_failoverPartner	= DEF_FAILOVERPARTNER;
			_initialCatalog		= DEF_INITIALCATALOG;
			_integratedSecurity	= DEF_INTEGRATEDSECURITY;
			_loadBalanceTimeout	= DEF_LOADBALANCETIMEOUT;
			_maxPoolSize		= DEF_MAXPOOLSIZE;
			_minPoolSize		= DEF_MINPOOLSIZE;
			_multipleActiveResultSets= DEF_MULTIPLEACTIVERESULTSETS;
			_networkLibrary		= DEF_NETWORKLIBRARY;
			_packetSize		= DEF_PACKETSIZE;
			_password		= DEF_PASSWORD;
			_persistSecurityInfo	= DEF_PERSISTSECURITYINFO;
			_pooling		= DEF_POOLING;
			_replication		= DEF_REPLICATION;
			_userID			= DEF_USERID;
			_workstationID		= DEF_WORKSTATIONID;
			_trustServerCertificate	= DEF_TRUSTSERVERCERTIFICATE;
			_typeSystemVersion	= DEF_TYPESYSTEMVERSION;
			_userInstance		= DEF_USERINSTANCE;
			_contextConnection	= DEF_CONTEXTCONNECTION;
			_transactionBinding	= DEF_TRANSACTIONBINDING;
		}

		public override void Clear ()
		{
			base.Clear ();
			Init ();
		}

		public override bool ContainsKey (string keyword)
		{
			keyword = keyword.ToUpper ().Trim ();
			if (_keywords.ContainsKey (keyword))
				return base.ContainsKey (_keywords [keyword]);
			return false;
		}

		public override bool Remove (string keyword)
		{
			if (!ContainsKey (keyword))
				return false;
			this [keyword] = null;
			return true;
		}

		[MonoNotSupported ("")] // Note that base.ShouldSerialize() is called but not implemented
		public override bool ShouldSerialize (string keyword)
		{
			if (!ContainsKey (keyword))
				return false;
			keyword = keyword.ToUpper ().Trim ();
			// Assuming passwords cannot be serialized.
			if (_keywords [keyword] == "Password")
				return false;
			return base.ShouldSerialize (_keywords [keyword]);
		}

		public override bool TryGetValue (string keyword, out object value)
		{
			if (! ContainsKey (keyword)) {
				value = String.Empty;
				return false;
			}
			return base.TryGetValue (_keywords [keyword.ToUpper ().Trim ()], out value);
		}

		#endregion // Methods

		#region Private Methods
		private string MapKeyword (string keyword)
		{
			keyword = keyword.ToUpper ().Trim ();
			if (! _keywords.ContainsKey (keyword))
				throw new ArgumentException("Keyword not supported :" + keyword);
			return _keywords [keyword];
		}
		
		private void SetValue (string key, object value)
		{
			if (key == null)
				throw new ArgumentNullException ("key cannot be null!");

			string mappedKey = MapKeyword (key);

			switch (mappedKey.ToUpper ().Trim ()) {
			case "APPLICATION NAME" :
				if (value == null) {
					_applicationName = DEF_APPLICATIONNAME;
					base.Remove (mappedKey);
				} else
					this.ApplicationName = value.ToString ();
				break;
			case "ATTACHDBFILENAME" :
				throw new NotImplementedException ("Attachable database support is " +
								   "not implemented.");
			case "CONNECT TIMEOUT" :
				if (value == null) {
					_connectTimeout = DEF_CONNECTTIMEOUT;
					base.Remove (mappedKey);
				} else 
					this.ConnectTimeout = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
				break;
			case "CONNECTION LIFETIME" :
				break;
			case "CONNECTION RESET" :
				if (value == null) {
					_connectionReset = DEF_CONNECTIONRESET;
					base.Remove (mappedKey);
				} else 
					this.ConnectionReset = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
				break;
			case "CURRENT LANGUAGE" :
				if (value == null) {
					_currentLanguage = DEF_CURRENTLANGUAGE;
					base.Remove (mappedKey);
				} else 
					this.CurrentLanguage = value.ToString ();
				break;
			case "CONTEXT CONNECTION" :
				if (value == null) {
					_contextConnection = DEF_CONTEXTCONNECTION;
					base.Remove (mappedKey);
				} else
					this.ContextConnection = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
				break;
			case "DATA SOURCE" :
				if (value == null) {
					_dataSource = DEF_DATASOURCE;
					base.Remove (mappedKey);
				} else 
					this.DataSource = value.ToString ();
				break;
			case "ENCRYPT":
				if (value == null) {
					_encrypt = DEF_ENCRYPT;
					base.Remove (mappedKey);
				}else if (DbConnectionStringBuilderHelper.ConvertToBoolean(value))
					throw new NotImplementedException("SSL encryption for"
									  + " data sent between client and server is not"
									  + " implemented.");
				break;
			case "ENLIST" :
				if (value == null) {
					_enlist = DEF_ENLIST;
					base.Remove (mappedKey);
				} else if ( ! DbConnectionStringBuilderHelper.ConvertToBoolean(value))
					throw new NotImplementedException("Disabling the automatic"
									  + " enlistment of connections in the thread's current"
									  + " transaction context is not implemented.");
				break;
			case "INITIAL CATALOG" :
				if (value == null) {
					_initialCatalog = DEF_INITIALCATALOG;
					base.Remove (mappedKey);
				} else 
					this.InitialCatalog = value.ToString ();
				break;
			case "INTEGRATED SECURITY" :
				if (value == null) {
					_integratedSecurity = DEF_INTEGRATEDSECURITY;
					base.Remove (mappedKey);
				} else 
					this.IntegratedSecurity = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
				break;
			case "MAX POOL SIZE" :
				if (value == null) {
					_maxPoolSize = DEF_MAXPOOLSIZE;
					base.Remove (mappedKey);
				} else 
					this.MaxPoolSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
				break;
			case "MIN POOL SIZE" :
				if (value == null) {
					_minPoolSize = DEF_MINPOOLSIZE;
					base.Remove (mappedKey);
				} else 
					this.MinPoolSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
				break;
			case "MULTIPLEACTIVERESULTSETS":
				if (value == null) {
					_multipleActiveResultSets = DEF_MULTIPLEACTIVERESULTSETS;
					base.Remove (mappedKey);
				} else if ( DbConnectionStringBuilderHelper.ConvertToBoolean (value))
					throw new NotImplementedException ("MARS is not yet implemented!");
				break;
			case "ASYNCHRONOUS PROCESSING" :
				if (value == null) {
					_asynchronousProcessing = DEF_ASYNCHRONOUSPROCESSING;
					base.Remove (mappedKey);
				} else 
					this.AsynchronousProcessing = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
				break;
			case "NETWORK LIBRARY" :
				if (value == null) {
					_networkLibrary = DEF_NETWORKLIBRARY;
					base.Remove (mappedKey);
				} else {
					if (!value.ToString ().ToUpper ().Equals ("DBMSSOCN"))
						throw new ArgumentException ("Unsupported network library.");
					this.NetworkLibrary = value.ToString ().ToLower ();
				}
				break;
			case "LOAD BALANCE TIMEOUT":
				// TODO: what is this?
				break;
			case "PACKET SIZE" :
				if (value == null) {
					_packetSize = DEF_PACKETSIZE;
					base.Remove (mappedKey);
				} else 
					this.PacketSize = DbConnectionStringBuilderHelper.ConvertToInt32 (value);
				break;
			case "PASSWORD" :
				if (value == null) {
					_password = DEF_PASSWORD;
					base.Remove (mappedKey);
				} else 
					this.Password = value.ToString ();
				break;
			case "PERSIST SECURITY INFO" :
				if (value == null) {
					_persistSecurityInfo = DEF_PERSISTSECURITYINFO;
					base.Remove (mappedKey);
				} else if (DbConnectionStringBuilderHelper.ConvertToBoolean (value))
					throw new NotImplementedException ("Persisting security info" +
									   " is not yet implemented");
				break;
			case "POOLING" :
				if (value == null) {
					_pooling = DEF_POOLING;
					base.Remove (mappedKey);
				} else 
					this.Pooling = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
				break;
			case "USER ID" :
				if (value == null) {
					_userID = DEF_USERID;
					base.Remove (mappedKey);
				} else 
					this.UserID = value.ToString ();
				break;
			case "USER INSTANCE" :
				if (value == null) {
					_userInstance = DEF_USERINSTANCE;
					base.Remove (mappedKey);
				} else
					this.UserInstance = DbConnectionStringBuilderHelper.ConvertToBoolean (value);
				break;
			case "WORKSTATION ID" :
				if (value == null) {
					_workstationID = DEF_WORKSTATIONID;
					base.Remove (mappedKey);
				} else 
					this.WorkstationID = value.ToString ();
				break;
			case "TRANSACTION BINDING":
				// TODO: what is this?
				break;
			default :
				throw new ArgumentException("Keyword not supported :" + key);
			}
		}
		#endregion // Private Methods
	}
 
	
}
#endif // NET_2_0
Back to Top