@@ -35,7 +35,7 @@ private static Stream OpenStream(string configFileName)
35
35
36
36
if ( true )
37
37
{
38
- int count = 0 ;
38
+ var count = 0 ;
39
39
40
40
while ( true )
41
41
{
@@ -101,7 +101,7 @@ private static Type GetType(string typeName)
101
101
/// <returns></returns>
102
102
private bool FindSection ( string sectionName )
103
103
{
104
- bool found = false ;
104
+ var found = false ;
105
105
106
106
while ( this . xmlReader . Read ( ) )
107
107
{
@@ -120,17 +120,17 @@ private bool FindSection(string sectionName)
120
120
121
121
private object ReadAttributeValueArray ( Type elementType )
122
122
{
123
- List < object > list = new List < object > ( ) ;
124
- bool go = ! this . xmlReader . IsEmptyElement ;
123
+ var list = new List < object > ( ) ;
124
+ var go = ! this . xmlReader . IsEmptyElement ;
125
125
126
126
while ( go && this . xmlReader . Read ( ) )
127
127
{
128
128
switch ( this . xmlReader . NodeType )
129
129
{
130
130
case XmlNodeType . Element :
131
131
{
132
- string valueStr = this . xmlReader [ "value" ] ;
133
- object value = Convert . ChangeType ( valueStr , elementType , this . formatProvider ) ;
132
+ var valueStr = this . xmlReader [ "value" ] ;
133
+ var value = Convert . ChangeType ( valueStr , elementType , this . formatProvider ) ;
134
134
list . Add ( value ) ;
135
135
}
136
136
@@ -165,7 +165,7 @@ private object ReadAttributeValue(Type type)
165
165
166
166
if ( typeCode == TypeCode . Byte )
167
167
{
168
- string innerXml = this . xmlReader . ReadInnerXml ( ) ;
168
+ var innerXml = this . xmlReader . ReadInnerXml ( ) ;
169
169
value = System . Convert . FromBase64String ( innerXml ) ;
170
170
}
171
171
else
@@ -183,7 +183,7 @@ private object ReadAttributeValue(Type type)
183
183
{
184
184
while ( this . xmlReader . Read ( ) )
185
185
{
186
- bool isBreakable = false ;
186
+ var isBreakable = false ;
187
187
Trace . WriteLine ( this . xmlReader . NodeType ) ;
188
188
189
189
switch ( this . xmlReader . NodeType )
@@ -208,14 +208,14 @@ private object ReadAttributeValue(Type type)
208
208
}
209
209
else if ( type == typeof ( XmlNode ) )
210
210
{
211
- string innerXml = this . xmlReader . ReadInnerXml ( ) ;
212
- XmlDocument document = new XmlDocument ( ) ;
211
+ var innerXml = this . xmlReader . ReadInnerXml ( ) ;
212
+ var document = new XmlDocument ( ) ;
213
213
document . LoadXml ( innerXml ) ;
214
214
value = document . DocumentElement ;
215
215
}
216
216
else
217
217
{
218
- string innerXml = this . xmlReader . ReadInnerXml ( ) ;
218
+ var innerXml = this . xmlReader . ReadInnerXml ( ) ;
219
219
value = XmlSerializerHelper . Deserialize ( innerXml , type ) ;
220
220
}
221
221
@@ -228,7 +228,7 @@ private void AddError(
228
228
Exception e )
229
229
{
230
230
string message2 = null ;
231
- IXmlLineInfo lineInfo = this . xmlReader as IXmlLineInfo ;
231
+ var lineInfo = this . xmlReader as IXmlLineInfo ;
232
232
233
233
if ( lineInfo != null && lineInfo . HasLineInfo ( ) )
234
234
{
@@ -245,7 +245,7 @@ private void AddError(
245
245
private void ReadAttribute ( ConfigurationNode node )
246
246
{
247
247
ConfigurationAttribute attribute = null ;
248
- string name = this . xmlReader [ "name" ] ;
248
+ var name = this . xmlReader [ "name" ] ;
249
249
object value = null ;
250
250
251
251
try
@@ -255,14 +255,14 @@ private void ReadAttribute(ConfigurationNode node)
255
255
this . AddError ( ErrorType . Warning , "name attribute not found" , null ) ;
256
256
}
257
257
258
- string typeName = this . xmlReader [ "type" ] ;
259
- Type type = GetType ( typeName ) ;
258
+ var typeName = this . xmlReader [ "type" ] ;
259
+ var type = GetType ( typeName ) ;
260
260
261
261
if ( type != null )
262
262
{
263
- string isNullStr = this . xmlReader [ "isNull" ] ;
264
- bool isNull = false ;
265
- string description = this . xmlReader [ "description" ] ;
263
+ var isNullStr = this . xmlReader [ "isNull" ] ;
264
+ var isNull = false ;
265
+ var description = this . xmlReader [ "description" ] ;
266
266
267
267
if ( isNullStr != null )
268
268
{
@@ -278,7 +278,7 @@ private void ReadAttribute(ConfigurationNode node)
278
278
279
279
if ( ! isNull )
280
280
{
281
- string valueStr = this . xmlReader [ "value" ] ;
281
+ var valueStr = this . xmlReader [ "value" ] ;
282
282
283
283
try
284
284
{
@@ -324,17 +324,17 @@ private void ReadAttribute(ConfigurationNode node)
324
324
325
325
private void Read ( ConfigurationNode node , StringCollection fileNames )
326
326
{
327
- string name = node . Name ;
328
- bool endOfNode = this . xmlReader . IsEmptyElement ;
327
+ var name = node . Name ;
328
+ var endOfNode = this . xmlReader . IsEmptyElement ;
329
329
330
330
if ( name != null )
331
331
{
332
- bool hasNext = this . xmlReader . MoveToFirstAttribute ( ) ;
332
+ var hasNext = this . xmlReader . MoveToFirstAttribute ( ) ;
333
333
334
334
while ( hasNext )
335
335
{
336
- string attributeName = this . xmlReader . Name ;
337
- string attributeValue = this . xmlReader . Value ;
336
+ var attributeName = this . xmlReader . Name ;
337
+ var attributeValue = this . xmlReader . Value ;
338
338
339
339
if ( attributeName == "name" )
340
340
{
@@ -345,7 +345,7 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
345
345
}
346
346
else
347
347
{
348
- ConfigurationAttribute attribute = new ConfigurationAttribute ( attributeName , attributeValue , null ) ;
348
+ var attribute = new ConfigurationAttribute ( attributeName , attributeValue , null ) ;
349
349
node . Attributes . Add ( attribute ) ;
350
350
}
351
351
@@ -359,7 +359,7 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
359
359
{
360
360
case XmlNodeType . Element :
361
361
{
362
- string elementName = this . xmlReader . Name ;
362
+ var elementName = this . xmlReader . Name ;
363
363
364
364
switch ( elementName )
365
365
{
@@ -369,8 +369,8 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
369
369
370
370
case ConfigurationElementName . Node :
371
371
{
372
- string nodeName = this . xmlReader . GetAttribute ( "name" ) ;
373
- ConfigurationNode childNode = new ConfigurationNode ( nodeName ) ;
372
+ var nodeName = this . xmlReader . GetAttribute ( "name" ) ;
373
+ var childNode = new ConfigurationNode ( nodeName ) ;
374
374
node . AddChildNode ( childNode ) ;
375
375
this . Read ( childNode , fileNames ) ;
376
376
}
@@ -379,14 +379,14 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
379
379
380
380
case "include" :
381
381
{
382
- string fileName = this . xmlReader . GetAttribute ( "fileName" ) ;
382
+ var fileName = this . xmlReader . GetAttribute ( "fileName" ) ;
383
383
fileName = Environment . ExpandEnvironmentVariables ( fileName ) ;
384
384
385
385
var reader2 = new ConfigurationReader ( ) ;
386
- ConfigurationNode includeNode = reader2 . Read ( fileName , this . sectionName , fileNames ) ;
386
+ var includeNode = reader2 . Read ( fileName , this . sectionName , fileNames ) ;
387
387
node . Attributes . Add ( includeNode . Attributes ) ;
388
388
389
- foreach ( ConfigurationNode childNode in includeNode . ChildNodes )
389
+ foreach ( var childNode in includeNode . ChildNodes )
390
390
{
391
391
node . AddChildNode ( childNode ) ;
392
392
}
@@ -401,8 +401,8 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
401
401
402
402
default :
403
403
{
404
- string nodeName = XmlConvert . DecodeName ( elementName ) ;
405
- ConfigurationNode childNode = new ConfigurationNode ( nodeName ) ;
404
+ var nodeName = XmlConvert . DecodeName ( elementName ) ;
405
+ var childNode = new ConfigurationNode ( nodeName ) ;
406
406
node . AddChildNode ( childNode ) ;
407
407
this . Read ( childNode , fileNames ) ;
408
408
}
@@ -425,15 +425,15 @@ private void Read(ConfigurationNode node, StringCollection fileNames)
425
425
426
426
private void InitCultureInfo ( )
427
427
{
428
- string cultureInfo = this . xmlReader [ "cultureInfo" ] ;
428
+ var cultureInfo = this . xmlReader [ "cultureInfo" ] ;
429
429
430
430
if ( cultureInfo != null )
431
431
{
432
432
try
433
433
{
434
434
try
435
435
{
436
- int culture = int . Parse ( cultureInfo , CultureInfo . InvariantCulture ) ;
436
+ var culture = int . Parse ( cultureInfo , CultureInfo . InvariantCulture ) ;
437
437
this . formatProvider = new CultureInfo ( culture ) ;
438
438
}
439
439
catch
@@ -468,7 +468,7 @@ public ConfigurationNode Read(
468
468
StringCollection fileNames )
469
469
{
470
470
log . Trace ( "ConfigurationReader.Read({0},{1})..." , configFilename , sectionName ) ;
471
- long startTick = Stopwatch . GetTimestamp ( ) ;
471
+ var startTick = Stopwatch . GetTimestamp ( ) ;
472
472
this . xmlReader = xmlReader ;
473
473
this . fileName = configFilename ;
474
474
this . sectionName = sectionName ;
@@ -477,11 +477,11 @@ public ConfigurationNode Read(
477
477
478
478
try
479
479
{
480
- bool found = this . FindSection ( sectionName ) ;
480
+ var found = this . FindSection ( sectionName ) ;
481
481
482
482
if ( found )
483
483
{
484
- XmlNodeType nodeType = xmlReader . MoveToContent ( ) ;
484
+ var nodeType = xmlReader . MoveToContent ( ) ;
485
485
486
486
if ( nodeType == XmlNodeType . Element )
487
487
{
@@ -512,10 +512,10 @@ public ConfigurationNode Read(
512
512
this . AddError ( ErrorType . Error , null , e ) ;
513
513
}
514
514
515
- long ticks = Stopwatch . GetTimestamp ( ) - startTick ;
515
+ var ticks = Stopwatch . GetTimestamp ( ) - startTick ;
516
516
message = $ "{ configFilename } loaded successfully in { StopwatchTimeSpan . ToString ( ticks , 3 ) } .";
517
517
LogLevel logLevel ;
518
- IEnumerable < Error > source = this . errors . Where ( e => e . Type == ErrorType . Error ) ;
518
+ var source = this . errors . Where ( e => e . Type == ErrorType . Error ) ;
519
519
520
520
if ( source . Any ( ) )
521
521
{
@@ -553,7 +553,7 @@ public ConfigurationNode Read(
553
553
{
554
554
ConfigurationNode node = null ;
555
555
556
- using ( Stream stream = OpenStream ( configFileName ) )
556
+ using ( var stream = OpenStream ( configFileName ) )
557
557
{
558
558
if ( stream != null )
559
559
{
@@ -573,13 +573,13 @@ public ConfigurationNode Read(
573
573
public ConfigurationNode Read ( XmlReader xmlReader )
574
574
{
575
575
this . xmlReader = xmlReader ;
576
- ConfigurationNode node = new ConfigurationNode ( null ) ;
577
- StringCollection fileNames = new StringCollection ( ) ;
576
+ var node = new ConfigurationNode ( null ) ;
577
+ var fileNames = new StringCollection ( ) ;
578
578
this . Read ( node , fileNames ) ;
579
579
580
580
if ( node . ChildNodes . Count == 1 )
581
581
{
582
- ConfigurationNode childNode = node . ChildNodes [ 0 ] ;
582
+ var childNode = node . ChildNodes [ 0 ] ;
583
583
node . RemoveChildNode ( childNode ) ;
584
584
node = childNode ;
585
585
}
0 commit comments