@@ -26,7 +26,7 @@ public class TaosConnectionStringBuilder : DbConnectionStringBuilder
2626 private const string DataBaseKeyword = "DataBase" ;
2727 private const string PortKeyword = "Port" ;
2828 private const string PoolSizeKeyword = "PoolSize" ;
29-
29+ private const string TimeOutKeyword = "TimeOut" ;
3030 private enum Keywords
3131 {
3232 DataSource ,
@@ -35,7 +35,9 @@ private enum Keywords
3535 Password ,
3636 Port ,
3737 Charset ,
38- PoolSize
38+ PoolSize ,
39+ TimeOut
40+
3941
4042 }
4143
@@ -48,21 +50,23 @@ private enum Keywords
4850 private string _charset = System . Text . Encoding . UTF8 . EncodingName ;
4951 private string _password = string . Empty ;
5052 private int _port = 6030 ;
51- private int _PoolSize = 8 ;
53+ private int _PoolSize = Environment . ProcessorCount ;
54+ private int _timeout = 30 ;
5255
5356 static TaosConnectionStringBuilder ( )
5457 {
55- var validKeywords = new string [ 7 ] ;
58+ var validKeywords = new string [ 8 ] ;
5659 validKeywords [ ( int ) Keywords . DataSource ] = DataSourceKeyword ;
5760 validKeywords [ ( int ) Keywords . DataBase ] = DataBaseKeyword ;
5861 validKeywords [ ( int ) Keywords . Username ] = UserNameKeyword ;
5962 validKeywords [ ( int ) Keywords . Password ] = PasswordKeyword ;
6063 validKeywords [ ( int ) Keywords . Charset ] = CharsetKeyword ;
6164 validKeywords [ ( int ) Keywords . Port ] = PortKeyword ;
6265 validKeywords [ ( int ) Keywords . PoolSize ] = PoolSizeKeyword ;
66+ validKeywords [ ( int ) Keywords . TimeOut ] = TimeOutKeyword ;
6367 _validKeywords = validKeywords ;
6468
65- _keywords = new Dictionary < string , Keywords > ( 7 , StringComparer . OrdinalIgnoreCase )
69+ _keywords = new Dictionary < string , Keywords > ( 8 , StringComparer . OrdinalIgnoreCase )
6670 {
6771 [ DataSourceKeyword ] = Keywords . DataSource ,
6872 [ UserNameKeyword ] = Keywords . Username ,
@@ -71,7 +75,8 @@ static TaosConnectionStringBuilder()
7175 [ CharsetKeyword ] = Keywords . Charset ,
7276 [ DataSourceNoSpaceKeyword ] = Keywords . DataSource ,
7377 [ PortKeyword ] = Keywords . Port ,
74- [ PoolSizeKeyword ] = Keywords . PoolSize
78+ [ PoolSizeKeyword ] = Keywords . PoolSize ,
79+ [ TimeOutKeyword ] = Keywords . TimeOut
7580 } ;
7681 }
7782
@@ -100,6 +105,8 @@ public virtual string DataSource
100105 get => _dataSource ;
101106 set => base [ DataSourceKeyword ] = _dataSource = value ;
102107 }
108+
109+
103110 public virtual string Username
104111 {
105112 get => _userName ;
@@ -164,7 +171,13 @@ public virtual string DataBase
164171 }
165172 internal bool ForceDatabaseName { get ; set ; } = false ;
166173
174+
167175
176+ public int ConnectionTimeout
177+ {
178+ get => _timeout ;
179+ set => base [ TimeOutKeyword ] = _timeout = value ;
180+ }
168181
169182 /// <summary>
170183 /// Gets or sets the value associated with the specified key.
@@ -206,6 +219,9 @@ public override object this[string keyword]
206219 case Keywords . PoolSize :
207220 PoolSize = Convert . ToInt32 ( value , CultureInfo . InvariantCulture ) ;
208221 return ;
222+ case Keywords . TimeOut :
223+ ConnectionTimeout = Convert . ToInt32 ( value , CultureInfo . InvariantCulture ) ;
224+ return ;
209225 default :
210226 Debug . Assert ( false , "Unexpected keyword: " + keyword ) ;
211227 return ;
@@ -330,6 +346,8 @@ private object GetAt(Keywords index)
330346 return Charset ;
331347 case Keywords . PoolSize :
332348 return PoolSize ;
349+ case Keywords . TimeOut :
350+ return ConnectionTimeout ;
333351 default :
334352 Debug . Assert ( false , "Unexpected keyword: " + index ) ;
335353 return null ;
@@ -358,13 +376,16 @@ private void Reset(Keywords index)
358376 _dataBase = string . Empty ;
359377 return ;
360378 case Keywords . Port :
361- _port = 6060 ;
379+ _port = 6030 ;
362380 return ;
363381 case Keywords . Charset :
364382 _charset = System . Text . Encoding . UTF8 . EncodingName ;
365383 return ;
366384 case Keywords . PoolSize :
367- _PoolSize = 8 ;
385+ _PoolSize = Environment . ProcessorCount ;
386+ return ;
387+ case Keywords . TimeOut :
388+ _timeout = 30 ;
368389 return ;
369390 default :
370391 Debug . Assert ( false , "Unexpected keyword: " + index ) ;
0 commit comments