@@ -26,10 +26,7 @@ public virtual string this[string key]
2626 set => _col [ key ] = value ;
2727 }
2828
29- public virtual void Add ( string key , string value )
30- {
31- _col [ key ] = value ;
32- }
29+ public virtual void Add ( string key , string value ) => _col [ key ] = value ;
3330
3431 public void AddAll ( Properties col )
3532 {
@@ -44,22 +41,21 @@ public void AddAll(Properties col)
4441 }
4542 }
4643
47- public void Clear ( )
48- {
49- _col . Clear ( ) ;
50- }
44+ public void Clear ( ) => _col . Clear ( ) ;
5145
5246 public bool ContainsKey ( string key ) => _col . ContainsKey ( key ) ;
5347
5448 public IEnumerator < KeyValuePair < string , string > > GetEnumerator ( ) => _col . GetEnumerator ( ) ;
5549
5650 public void Load ( Stream inStream )
5751 {
58- using var inp = new StreamReader ( inStream , EncodingsRegistry . GetEncoding ( 1252 ) ) ;
52+ using var inp = new StreamReader ( inStream , EncodingsRegistry . GetEncoding ( codepage : 1252 ) ) ;
53+
5954 while ( true )
6055 {
6156 // Get next line
6257 var line = inp . ReadLine ( ) ;
58+
6359 if ( line == null )
6460 {
6561 return ;
@@ -70,6 +66,7 @@ public void Load(Stream inStream)
7066 // Find start of key
7167 var len = line . Length ;
7268 int keyStart ;
69+
7370 for ( keyStart = 0 ; keyStart < len ; keyStart ++ )
7471 {
7572 if ( WhiteSpaceChars . IndexOf ( line [ keyStart ] . ToString ( ) , StringComparison . Ordinal ) == - 1 )
@@ -86,19 +83,23 @@ public void Load(Stream inStream)
8683
8784 // Continue lines that end in slashes if they are not comments
8885 var firstChar = line [ keyStart ] ;
86+
8987 if ( firstChar != '#' && firstChar != '!' )
9088 {
9189 while ( continueLine ( line ) )
9290 {
9391 var nextLine = inp . ReadLine ( ) ;
92+
9493 if ( nextLine == null )
9594 {
9695 nextLine = "" ;
9796 }
9897
99- var loppedLine = line . Substring ( 0 , len - 1 ) ;
98+ var loppedLine = line . Substring ( startIndex : 0 , len - 1 ) ;
99+
100100 // Advance beyond whitespace on new line
101101 int startIndex ;
102+
102103 for ( startIndex = 0 ; startIndex < nextLine . Length ; startIndex ++ )
103104 {
104105 if ( WhiteSpaceChars . IndexOf ( nextLine [ startIndex ] . ToString ( ) , StringComparison . Ordinal ) ==
@@ -108,16 +109,18 @@ public void Load(Stream inStream)
108109 }
109110 }
110111
111- nextLine = nextLine . Substring ( startIndex , nextLine . Length - startIndex ) ;
112+ nextLine = nextLine . Substring ( startIndex ) ;
112113 line = loppedLine + nextLine ;
113114 len = line . Length ;
114115 }
115116
116117 // Find separation between key and value
117118 int separatorIndex ;
119+
118120 for ( separatorIndex = keyStart ; separatorIndex < len ; separatorIndex ++ )
119121 {
120122 var currentChar = line [ separatorIndex ] ;
123+
121124 if ( currentChar == '\\ ' )
122125 {
123126 separatorIndex ++ ;
@@ -130,6 +133,7 @@ public void Load(Stream inStream)
130133
131134 // Skip over whitespace after key if any
132135 int valueIndex ;
136+
133137 for ( valueIndex = separatorIndex ; valueIndex < len ; valueIndex ++ )
134138 {
135139 if ( WhiteSpaceChars . IndexOf ( line [ valueIndex ] . ToString ( ) , StringComparison . Ordinal ) == - 1 )
@@ -175,13 +179,15 @@ public string Remove(string key)
175179 {
176180 var retval = _col [ key ] ;
177181 _col . Remove ( key ) ;
182+
178183 return retval ;
179184 }
180185
181186 private static bool continueLine ( string line )
182187 {
183188 var slashCount = 0 ;
184189 var index = line . Length - 1 ;
190+
185191 while ( index >= 0 && line [ index -- ] == '\\ ' )
186192 {
187193 slashCount ++ ;
@@ -203,16 +209,20 @@ private static string loadConvert(string theString)
203209 for ( var x = 0 ; x < len ; )
204210 {
205211 aChar = theString [ x ++ ] ;
212+
206213 if ( aChar == '\\ ' )
207214 {
208215 aChar = theString [ x ++ ] ;
216+
209217 if ( aChar == 'u' )
210218 {
211219 // Read the xxxx
212220 var value = 0 ;
221+
213222 for ( var i = 0 ; i < 4 ; i ++ )
214223 {
215224 aChar = theString [ x ++ ] ;
225+
216226 switch ( aChar )
217227 {
218228 case '0' :
@@ -226,6 +236,7 @@ private static string loadConvert(string theString)
226236 case '8' :
227237 case '9' :
228238 value = ( value << 4 ) + aChar - '0' ;
239+
229240 break ;
230241 case 'a' :
231242 case 'b' :
@@ -234,6 +245,7 @@ private static string loadConvert(string theString)
234245 case 'e' :
235246 case 'f' :
236247 value = ( value << 4 ) + 10 + aChar - 'a' ;
248+
237249 break ;
238250 case 'A' :
239251 case 'B' :
@@ -242,10 +254,10 @@ private static string loadConvert(string theString)
242254 case 'E' :
243255 case 'F' :
244256 value = ( value << 4 ) + 10 + aChar - 'A' ;
257+
245258 break ;
246259 default :
247- throw new ArgumentException (
248- "Malformed \\ uxxxx encoding." ) ;
260+ throw new ArgumentException ( message : "Malformed \\ uxxxx encoding." ) ;
249261 }
250262 }
251263
0 commit comments