@@ -14,32 +14,6 @@ namespace Datadog.Trace.Configuration.Telemetry;
14
14
15
15
internal readonly struct ConfigurationBuilder
16
16
{
17
- // static accessor functions
18
- private static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < string , bool > ? , bool , ConfigurationResult < string > > AsStringSelector
19
- = ( source , key , telemetry , validator , recordValue ) => source . GetString ( key , telemetry , validator , recordValue ) ;
20
-
21
- private static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < bool , bool > ? , bool , ConfigurationResult < bool > > AsBoolSelector
22
- = ( source , key , telemetry , validator , _ ) => source . GetBool ( key , telemetry , validator ) ;
23
-
24
- private static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < int , bool > ? , bool , ConfigurationResult < int > > AsInt32Selector
25
- = ( source , key , telemetry , validator , _ ) => source . GetInt32 ( key , telemetry , validator ) ;
26
-
27
- private static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < double , bool > ? , bool , ConfigurationResult < double > > AsDoubleSelector
28
- = ( source , key , telemetry , validator , _ ) => source . GetDouble ( key , telemetry , validator ) ;
29
-
30
- // static accessor functions with converters
31
- private static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < string , bool > ? , Func < string , ParsingResult < string > > , bool , ConfigurationResult < string > > AsStringWithConverterSelector
32
- = ( source , key , telemetry , validator , converter , recordValue ) => source . GetAs ( key , telemetry , converter , validator , recordValue ) ;
33
-
34
- private static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < bool , bool > ? , Func < string , ParsingResult < bool > > , bool , ConfigurationResult < bool > > AsBoolWithConverterSelector
35
- = ( source , key , telemetry , validator , converter , _ ) => source . GetAs ( key , telemetry , converter , validator , recordValue : true ) ;
36
-
37
- private static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < int , bool > ? , Func < string , ParsingResult < int > > , bool , ConfigurationResult < int > > AsInt32WithConverterSelector
38
- = ( source , key , telemetry , validator , converter , _ ) => source . GetAs ( key , telemetry , converter , validator , recordValue : true ) ;
39
-
40
- private static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < double , bool > ? , Func < string , ParsingResult < double > > , bool , ConfigurationResult < double > > AsDoubleWithConverterSelector
41
- = ( source , key , telemetry , validator , converter , _ ) => source . GetAs ( key , telemetry , converter , validator , recordValue : true ) ;
42
-
43
17
private readonly IConfigurationSource _source ;
44
18
private readonly IConfigurationTelemetry _telemetry ;
45
19
@@ -374,23 +348,23 @@ public ClassConfigurationResultWithKey<IDictionary<string, string>> AsDictionary
374
348
375
349
private ConfigurationResult < string > GetStringResult ( Func < string , bool > ? validator , Func < string , ParsingResult < string > > ? converter , bool recordValue )
376
350
=> converter is null
377
- ? GetResult ( AsStringSelector , validator , recordValue )
378
- : GetResult ( AsStringWithConverterSelector , validator , converter , recordValue ) ;
351
+ ? GetResult ( Selectors . AsString , validator , recordValue )
352
+ : GetResult ( Selectors . AsStringWithConverter , validator , converter , recordValue ) ;
379
353
380
354
private ConfigurationResult < bool > GetBoolResult ( Func < bool , bool > ? validator , Func < string , ParsingResult < bool > > ? converter )
381
355
=> converter is null
382
- ? GetResult ( AsBoolSelector , validator , recordValue : true )
383
- : GetResult ( AsBoolWithConverterSelector , validator , converter , recordValue : true ) ;
356
+ ? GetResult ( Selectors . AsBool , validator , recordValue : true )
357
+ : GetResult ( Selectors . AsBoolWithConverter , validator , converter , recordValue : true ) ;
384
358
385
359
private ConfigurationResult < int > GetInt32Result ( Func < int , bool > ? validator , Func < string , ParsingResult < int > > ? converter )
386
360
=> converter is null
387
- ? GetResult ( AsInt32Selector , validator , recordValue : true )
388
- : GetResult ( AsInt32WithConverterSelector , validator , converter , recordValue : true ) ;
361
+ ? GetResult ( Selectors . AsInt32 , validator , recordValue : true )
362
+ : GetResult ( Selectors . AsInt32WithConverter , validator , converter , recordValue : true ) ;
389
363
390
364
private ConfigurationResult < double > GetDoubleResult ( Func < double , bool > ? validator , Func < string , ParsingResult < double > > ? converter )
391
365
=> converter is null
392
- ? GetResult ( AsDoubleSelector , validator , recordValue : true )
393
- : GetResult ( AsDoubleWithConverterSelector , validator , converter , recordValue : true ) ;
366
+ ? GetResult ( Selectors . AsDouble , validator , recordValue : true )
367
+ : GetResult ( Selectors . AsDoubleWithConverter , validator , converter , recordValue : true ) ;
394
368
395
369
private ConfigurationResult < T > GetAs < T > ( Func < T , bool > ? validator , Func < string , ParsingResult < T > > converter )
396
370
=> GetResult (
@@ -596,4 +570,33 @@ public T OverrideWith(in ClassConfigurationResultWithKey<T> otelConfig, IConfigu
596
570
return null ;
597
571
}
598
572
}
573
+
574
+ private static class Selectors
575
+ {
576
+ // static accessor functions
577
+ internal static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < string , bool > ? , bool , ConfigurationResult < string > > AsString
578
+ = ( source , key , telemetry , validator , recordValue ) => source . GetString ( key , telemetry , validator , recordValue ) ;
579
+
580
+ internal static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < bool , bool > ? , bool , ConfigurationResult < bool > > AsBool
581
+ = ( source , key , telemetry , validator , _ ) => source . GetBool ( key , telemetry , validator ) ;
582
+
583
+ internal static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < int , bool > ? , bool , ConfigurationResult < int > > AsInt32
584
+ = ( source , key , telemetry , validator , _ ) => source . GetInt32 ( key , telemetry , validator ) ;
585
+
586
+ internal static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < double , bool > ? , bool , ConfigurationResult < double > > AsDouble
587
+ = ( source , key , telemetry , validator , _ ) => source . GetDouble ( key , telemetry , validator ) ;
588
+
589
+ // static accessor functions with converters
590
+ internal static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < string , bool > ? , Func < string , ParsingResult < string > > , bool , ConfigurationResult < string > > AsStringWithConverter
591
+ = ( source , key , telemetry , validator , converter , recordValue ) => source . GetAs ( key , telemetry , converter , validator , recordValue ) ;
592
+
593
+ internal static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < bool , bool > ? , Func < string , ParsingResult < bool > > , bool , ConfigurationResult < bool > > AsBoolWithConverter
594
+ = ( source , key , telemetry , validator , converter , _ ) => source . GetAs ( key , telemetry , converter , validator , recordValue : true ) ;
595
+
596
+ internal static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < int , bool > ? , Func < string , ParsingResult < int > > , bool , ConfigurationResult < int > > AsInt32WithConverter
597
+ = ( source , key , telemetry , validator , converter , _ ) => source . GetAs ( key , telemetry , converter , validator , recordValue : true ) ;
598
+
599
+ internal static readonly Func < IConfigurationSource , string , IConfigurationTelemetry , Func < double , bool > ? , Func < string , ParsingResult < double > > , bool , ConfigurationResult < double > > AsDoubleWithConverter
600
+ = ( source , key , telemetry , validator , converter , _ ) => source . GetAs ( key , telemetry , converter , validator , recordValue : true ) ;
601
+ }
599
602
}
0 commit comments