@@ -307,10 +307,23 @@ public bool AsBool(bool defaultValue, Func<bool, bool>? validator)
307
307
public int ? AsInt32 ( int ? defaultValue , Func < int , bool > ? validator , Func < string , ParsingResult < int > > ? converter )
308
308
{
309
309
var result = GetInt32Result ( validator , converter ) ;
310
- Func < DefaultResult < int > > ? getDefaultValue = defaultValue . HasValue ? ( ) => defaultValue . Value : null ;
311
- return TryHandleResult ( Telemetry , Key , result , recordValue : true , getDefaultValue , out var value ) ? value : null ;
310
+ if ( result is { Result : { } ddResult , IsValid : true } )
311
+ {
312
+ return ddResult ;
313
+ }
314
+
315
+ if ( defaultValue is not { } value )
316
+ {
317
+ return null ;
318
+ }
319
+
320
+ Telemetry . Record ( Key , value , ConfigurationOrigins . Default ) ;
321
+ return value ;
312
322
}
313
323
324
+ // ****************
325
+ // Double accessors
326
+ // ****************
314
327
public double ? AsDouble ( ) => AsDouble ( defaultValue : null , validator : null ) ;
315
328
316
329
public double AsDouble ( double defaultValue ) => AsDouble ( defaultValue , validator : null ) . Value ;
@@ -325,8 +338,18 @@ public bool AsBool(bool defaultValue, Func<bool, bool>? validator)
325
338
public double ? AsDouble ( double ? defaultValue , Func < double , bool > ? validator , Func < string , ParsingResult < double > > ? converter )
326
339
{
327
340
var result = GetDoubleResult ( validator , converter ) ;
328
- Func < DefaultResult < double > > ? getDefaultValue = defaultValue . HasValue ? ( ) => defaultValue . Value : null ;
329
- return TryHandleResult ( Telemetry , Key , result , recordValue : true , getDefaultValue , out var value ) ? value : null ;
341
+ if ( result is { Result : { } ddResult , IsValid : true } )
342
+ {
343
+ return ddResult ;
344
+ }
345
+
346
+ if ( defaultValue is not { } value )
347
+ {
348
+ return null ;
349
+ }
350
+
351
+ Telemetry . Record ( Key , value , ConfigurationOrigins . Default ) ;
352
+ return value ;
330
353
}
331
354
332
355
// ****************
0 commit comments