@@ -213,21 +213,23 @@ internal T GetValue<T>(string key, bool throwEx, out bool found)
213
213
// the below here should only be simple types, string, int, ...
214
214
else if ( typeof ( T ) == typeof ( string ) )
215
215
{
216
- return ( T ) ( ( object ) obj . ToString ( ) ) ;
216
+ if ( objType == typeof ( DateTime ) )
217
+ return ( T ) ( ( object ) ( ( DateTime ) obj ) . ToString ( "o" , CultureInfo . InvariantCulture ) ) ;
218
+
219
+ return ( T ) ( ( object ) obj . ToString ( ) ) ;
220
+ }
221
+ else if ( typeof ( T ) == typeof ( bool ) )
222
+ {
223
+ if ( bool . TryParse ( obj . ToString ( ) , out bool value ) )
224
+ return ( T ) ( object ) value ;
217
225
}
218
226
else if ( typeof ( T ) == typeof ( int ) )
219
227
{
220
- if ( objType == typeof ( int ) )
221
- return ( T ) obj ;
222
-
223
228
if ( int . TryParse ( obj . ToString ( ) , out int value ) )
224
229
return ( T ) ( object ) value ;
225
230
}
226
231
else if ( typeof ( T ) == typeof ( long ) )
227
232
{
228
- if ( objType == typeof ( long ) )
229
- return ( T ) obj ;
230
-
231
233
if ( objType == typeof ( int ) )
232
234
return ( T ) ( object ) ( long ) ( int ) obj ;
233
235
@@ -255,7 +257,6 @@ internal T GetValue<T>(string key, bool throwEx, out bool found)
255
257
256
258
return ( T ) ( object ) new Collection < string > { obj . ToString ( ) } ;
257
259
}
258
-
259
260
else if ( typeof ( T ) == typeof ( object [ ] ) )
260
261
return ( T ) ( object ) new object [ ] { obj } ;
261
262
@@ -267,9 +268,6 @@ internal T GetValue<T>(string key, bool throwEx, out bool found)
267
268
268
269
else if ( typeof ( T ) == typeof ( DateTime ) )
269
270
{
270
- if ( objType == typeof ( DateTime ) )
271
- return ( T ) obj ;
272
-
273
271
if ( DateTime . TryParse ( obj . ToString ( ) , out DateTime value ) )
274
272
return ( T ) ( object ) value ;
275
273
}
@@ -294,33 +292,26 @@ internal T GetValue<T>(string key, bool throwEx, out bool found)
294
292
}
295
293
else if ( typeof ( T ) == typeof ( double ) )
296
294
{
297
- if ( objType == typeof ( double ) )
298
- return ( T ) obj ;
299
-
300
295
if ( double . TryParse ( obj . ToString ( ) , out double value ) )
301
296
return ( T ) ( object ) value ;
302
297
}
303
298
else if ( typeof ( T ) == typeof ( uint ) )
304
299
{
305
- if ( objType == typeof ( uint ) )
306
- return ( T ) obj ;
307
-
308
300
if ( uint . TryParse ( obj . ToString ( ) , out uint value ) )
309
301
return ( T ) ( object ) value ;
310
302
}
303
+ else if ( typeof ( T ) == typeof ( ulong ) )
304
+ {
305
+ if ( ulong . TryParse ( obj . ToString ( ) , out ulong value ) )
306
+ return ( T ) ( object ) value ;
307
+ }
311
308
else if ( typeof ( T ) == typeof ( float ) )
312
309
{
313
- if ( objType == typeof ( float ) )
314
- return ( T ) obj ;
315
-
316
310
if ( float . TryParse ( obj . ToString ( ) , out float value ) )
317
311
return ( T ) ( object ) value ;
318
312
}
319
313
else if ( typeof ( T ) == typeof ( decimal ) )
320
314
{
321
- if ( objType == typeof ( decimal ) )
322
- return ( T ) obj ;
323
-
324
315
if ( decimal . TryParse ( obj . ToString ( ) , out decimal value ) )
325
316
return ( T ) ( object ) value ;
326
317
}
0 commit comments