22// The .NET Foundation licenses this file to you under the MIT license. 
33// See the LICENSE file in the project root for more information. 
44
5+ #if NETFRAMEWORK 
6+ 
57using  System ; 
68using  System . Collections . Generic ; 
79using  System . Data ; 
1214
1315namespace  Microsoft . Data . Common 
1416{ 
17+     // @TODO: Theoretically this class could be replaced with SqlConnectionString. 
18+     
1519    [ Serializable ]  // MDAC 83147 
16-     internal  sealed  class  DBConnectionString 
20+     internal  sealed  class  DbConnectionString 
1721    { 
1822        // instances of this class are intended to be immutable, i.e readonly 
1923        // used by permission classes so it is much easier to verify correctness 
2024        // when not worried about the class being modified during execution 
2125
22-         // @TODO: Remove in favor of DbConnectionStringKeywords 
23-         private  static   class  KEY 
24-         { 
25-             internal  const  string  Password  =  DbConnectionStringKeywords . Password ; 
26-             internal  const  string  PersistSecurityInfo  =  DbConnectionStringKeywords . PersistSecurityInfo ; 
27-             internal  const  string  Pwd  =  DbConnectionStringSynonyms . Pwd ; 
28-         } ;
29- 
3026        // this class is serializable with Everett, so ugly field names can't be changed 
3127        readonly  private  string  _encryptedUsersConnectionString ; 
3228
@@ -51,21 +47,21 @@ private static class KEY
5147        readonly  private  string  _encryptedActualConnectionString ; 
5248#pragma warning restore 169 
5349
54-         internal  DBConnectionString ( string  value ,  string  restrictions ,  KeyRestrictionBehavior  behavior ,  Dictionary < string ,  string >  synonyms ,  bool  useOdbcRules ) 
50+         internal  DbConnectionString ( string  value ,  string  restrictions ,  KeyRestrictionBehavior  behavior ,  Dictionary < string ,  string >  synonyms ,  bool  useOdbcRules ) 
5551            :  this ( new  DbConnectionOptions ( value ,  synonyms ) ,  restrictions ,  behavior ,  synonyms ,  false ) 
5652        { 
5753            // useOdbcRules is only used to parse the connection string, not to parse restrictions because values don't apply there 
5854            // the hashtable doesn't need clone since it isn't shared with anything else 
5955        } 
6056
61-         internal  DBConnectionString ( DbConnectionOptions  connectionOptions ) 
57+         internal  DbConnectionString ( DbConnectionOptions  connectionOptions ) 
6258            :  this ( connectionOptions ,  ( string ) null ,  KeyRestrictionBehavior . AllowOnly ,  null ,  true ) 
6359        { 
64-             // used by DBDataPermission to convert from DbConnectionOptions to DBConnectionString  
60+             // used by DBDataPermission to convert from DbConnectionOptions to DbConnectionString  
6561            // since backward compatibility requires Everett level classes 
6662        } 
6763
68-         private  DBConnectionString ( DbConnectionOptions  connectionOptions ,  string  restrictions ,  KeyRestrictionBehavior  behavior ,  Dictionary < string ,  string >  synonyms ,  bool  mustCloneDictionary ) 
64+         private  DbConnectionString ( DbConnectionOptions  connectionOptions ,  string  restrictions ,  KeyRestrictionBehavior  behavior ,  Dictionary < string ,  string >  synonyms ,  bool  mustCloneDictionary ) 
6965        {  // used by DBDataPermission 
7066            Debug . Assert ( connectionOptions  !=  null ,  "null connectionOptions" ) ; 
7167            switch  ( behavior ) 
@@ -101,13 +97,13 @@ private DBConnectionString(DbConnectionOptions connectionOptions, string restric
10197                // serialize out with '*' so already knows what we do.  Better this way 
10298                // than to treat password specially later on which causes problems. 
10399                const  string  star  =  "*" ; 
104-                 if  ( _parsetable . ContainsKey ( KEY . Password ) ) 
100+                 if  ( _parsetable . ContainsKey ( DbConnectionStringKeywords . Password ) ) 
105101                { 
106-                     _parsetable [ KEY . Password ]  =  star ; 
102+                     _parsetable [ DbConnectionStringKeywords . Password ]  =  star ; 
107103                } 
108-                 if  ( _parsetable . ContainsKey ( KEY . Pwd ) ) 
104+                 if  ( _parsetable . ContainsKey ( DbConnectionStringSynonyms . Pwd ) ) 
109105                { 
110-                     _parsetable [ KEY . Pwd ]  =  star ; 
106+                     _parsetable [ DbConnectionStringSynonyms . Pwd ]  =  star ; 
111107                } 
112108
113109                // replace user's password/pwd value with "*" in the linked list and build a new string 
@@ -121,7 +117,7 @@ private DBConnectionString(DbConnectionOptions connectionOptions, string restric
121117            } 
122118        } 
123119
124-         private  DBConnectionString ( DBConnectionString  connectionString ,  string [ ]  restrictionValues ,  KeyRestrictionBehavior  behavior ) 
120+         private  DbConnectionString ( DbConnectionString  connectionString ,  string [ ]  restrictionValues ,  KeyRestrictionBehavior  behavior ) 
125121        { 
126122            // used by intersect for two equal connection strings with different restrictions 
127123            _encryptedUsersConnectionString  =  connectionString . _encryptedUsersConnectionString ; 
@@ -198,7 +194,7 @@ internal bool ContainsKey(string keyword)
198194            return  _parsetable . ContainsKey ( keyword ) ; 
199195        } 
200196
201-         internal  DBConnectionString  Intersect ( DBConnectionString  entry ) 
197+         internal  DbConnectionString  Intersect ( DbConnectionString  entry ) 
202198        { 
203199            KeyRestrictionBehavior  behavior  =  _behavior ; 
204200            string [ ]  restrictionValues  =  null ; 
@@ -287,18 +283,18 @@ internal DBConnectionString Intersect(DBConnectionString entry)
287283            } 
288284
289285            // verify _hasPassword & _parsetable are in sync between Everett/Whidbey 
290-             Debug . Assert ( ! _hasPassword  ||  ContainsKey ( KEY . Password )  ||  ContainsKey ( KEY . Pwd ) ,  "OnDeserialized password mismatch this" ) ; 
291-             Debug . Assert ( entry  ==  null  ||  ! entry . _hasPassword  ||  entry . ContainsKey ( KEY . Password )  ||  entry . ContainsKey ( KEY . Pwd ) ,  "OnDeserialized password mismatch entry" ) ; 
286+             Debug . Assert ( ! _hasPassword  ||  ContainsKey ( DbConnectionStringKeywords . Password )  ||  ContainsKey ( DbConnectionStringSynonyms . Pwd ) ,  "OnDeserialized password mismatch this" ) ; 
287+             Debug . Assert ( entry  ==  null  ||  ! entry . _hasPassword  ||  entry . ContainsKey ( DbConnectionStringKeywords . Password )  ||  entry . ContainsKey ( DbConnectionStringSynonyms . Pwd ) ,  "OnDeserialized password mismatch entry" ) ; 
292288
293-             DBConnectionString  value  =  new  DBConnectionString ( this ,  restrictionValues ,  behavior ) ; 
289+             DbConnectionString  value  =  new  DbConnectionString ( this ,  restrictionValues ,  behavior ) ; 
294290            ValidateCombinedSet ( this ,  value ) ; 
295291            ValidateCombinedSet ( entry ,  value ) ; 
296292
297293            return  value ; 
298294        } 
299295
300296        [ Conditional ( "DEBUG" ) ] 
301-         private  void  ValidateCombinedSet ( DBConnectionString  componentSet ,  DBConnectionString  combinedSet ) 
297+         private  void  ValidateCombinedSet ( DbConnectionString  componentSet ,  DbConnectionString  combinedSet ) 
302298        { 
303299            Debug . Assert ( combinedSet  !=  null ,  "The combined connection string should not be null" ) ; 
304300            if  ( ( componentSet  !=  null )  &&  ( combinedSet . _restrictionValues  !=  null )  &&  ( componentSet . _restrictionValues  !=  null ) ) 
@@ -371,10 +367,10 @@ private bool IsRestrictedKeyword(string key)
371367            return  ( _restrictionValues  ==  null  ||  ( 0  >  Array . BinarySearch ( _restrictionValues ,  key ,  StringComparer . Ordinal ) ) ) ; 
372368        } 
373369
374-         internal  bool  IsSupersetOf ( DBConnectionString  entry ) 
370+         internal  bool  IsSupersetOf ( DbConnectionString  entry ) 
375371        { 
376-             Debug . Assert ( ! _hasPassword  ||  ContainsKey ( KEY . Password )  ||  ContainsKey ( KEY . Pwd ) ,  "OnDeserialized password mismatch this" ) ; 
377-             Debug . Assert ( ! entry . _hasPassword  ||  entry . ContainsKey ( KEY . Password )  ||  entry . ContainsKey ( KEY . Pwd ) ,  "OnDeserialized password mismatch entry" ) ; 
372+             Debug . Assert ( ! _hasPassword  ||  ContainsKey ( DbConnectionStringKeywords . Password )  ||  ContainsKey ( DbConnectionStringSynonyms . Pwd ) ,  "OnDeserialized password mismatch this" ) ; 
373+             Debug . Assert ( ! entry . _hasPassword  ||  entry . ContainsKey ( DbConnectionStringKeywords . Password )  ||  entry . ContainsKey ( DbConnectionStringSynonyms . Pwd ) ,  "OnDeserialized password mismatch entry" ) ; 
378374
379375            switch  ( _behavior ) 
380376            { 
@@ -481,10 +477,10 @@ static private string[] NoDuplicateUnion(string[] a, string[] b)
481477            return  restrictionValues ; 
482478        } 
483479
484-         private  static   string [ ]  ParseRestrictions ( string  restrictions ,  Dictionary < string ,  string >  synonyms ) 
480+         private  static   string [ ]  ParseRestrictions ( string  restrictions ,  IReadOnlyDictionary < string ,  string >  synonyms ) 
485481        { 
486482#if DEBUG 
487-             SqlClientEventSource . Log . TryAdvancedTraceEvent ( "<comm.DBConnectionString |INFO|ADV> Restrictions='{0}'" ,  restrictions ) ; 
483+             SqlClientEventSource . Log . TryAdvancedTraceEvent ( "<comm.DbConnectionString |INFO|ADV> Restrictions='{0}'" ,  restrictions ) ; 
488484#endif
489485            List < string >  restrictionValues  =  new  List < string > ( ) ; 
490486            StringBuilder  buffer  =  new  StringBuilder ( restrictions . Length ) ; 
@@ -500,7 +496,7 @@ private static string[] ParseRestrictions(string restrictions, Dictionary<string
500496                if  ( ! string . IsNullOrEmpty ( keyname ) ) 
501497                { 
502498#if DEBUG 
503-                     SqlClientEventSource . Log . TryAdvancedTraceEvent ( "<comm.DBConnectionString |INFO|ADV> KeyName='{0}'" ,  keyname ) ; 
499+                     SqlClientEventSource . Log . TryAdvancedTraceEvent ( "<comm.DbConnectionString |INFO|ADV> KeyName='{0}'" ,  keyname ) ; 
504500#endif
505501                    string  realkeyname  =  synonyms  !=  null  ?  ( string ) synonyms [ keyname ]  :  keyname ;  // MDAC 85144 
506502                    if  ( string . IsNullOrEmpty ( realkeyname ) ) 
@@ -568,3 +564,5 @@ private static void Verify(string[] restrictionValues)
568564        } 
569565    } 
570566} 
567+ 
568+ #endif
0 commit comments