@@ -313,37 +313,27 @@ private static bool TryGetDeployment(Dictionary<object, object?> dictionary, Lis
313313 applicability = null ;
314314 var d = new DeploymentApplicability ( ) ;
315315 var assigned = false ;
316- if ( TryGetApplicabilityOverTime ( dictionary , "ece" , diagnostics , out var ece ) )
317- {
318- d . Ece = ece ;
319- assigned = true ;
320- }
321-
322- if ( TryGetApplicabilityOverTime ( dictionary , "eck" , diagnostics , out var eck ) )
323- {
324- d . Eck = eck ;
325- assigned = true ;
326- }
327316
328- if ( TryGetApplicabilityOverTime ( dictionary , "ess" , diagnostics , out var ess ) )
317+ var mapping = new Dictionary < string , Action < AppliesCollection ? > >
329318 {
330- d . Ess = ess ;
331- assigned = true ;
332- }
319+ { "ece" , a => d . Ece = a } ,
320+ { "eck" , a => d . Eck = a } ,
321+ { "ess" , a => d . Ess = a } ,
322+ { "self" , a => d . Self = a }
323+ } ;
333324
334- if ( TryGetApplicabilityOverTime ( dictionary , "self" , diagnostics , out var self ) )
325+ foreach ( var ( key , action ) in mapping )
335326 {
336- d . Self = self ;
327+ if ( ! TryGetApplicabilityOverTime ( dictionary , key , diagnostics , out var collection ) )
328+ continue ;
329+ action ( collection ) ;
337330 assigned = true ;
338331 }
339332
340- if ( assigned )
341- {
342- applicability = d ;
343- return true ;
344- }
345-
346- return false ;
333+ if ( ! assigned )
334+ return false ;
335+ applicability = d ;
336+ return true ;
347337 }
348338
349339 private static bool TryGetProjectApplicability ( Dictionary < object , object ? > dictionary ,
@@ -353,21 +343,19 @@ private static bool TryGetProjectApplicability(Dictionary<object, object?> dicti
353343 applicability = null ;
354344 var serverlessAvailability = new ServerlessProjectApplicability ( ) ;
355345 var assigned = false ;
356- if ( TryGetApplicabilityOverTime ( dictionary , "elasticsearch" , diagnostics , out var elasticsearch ) )
357- {
358- serverlessAvailability . Elasticsearch = elasticsearch ;
359- assigned = true ;
360- }
361346
362- if ( TryGetApplicabilityOverTime ( dictionary , "observability" , diagnostics , out var observability ) )
347+ var mapping = new Dictionary < string , Action < AppliesCollection ? > >
363348 {
364- serverlessAvailability . Observability = observability ;
365- assigned = true ;
366- }
349+ [ "elasticsearch" ] = a => serverlessAvailability . Elasticsearch = a ,
350+ [ "observability" ] = a => serverlessAvailability . Observability = a ,
351+ [ "security" ] = a => serverlessAvailability . Security = a
352+ } ;
367353
368- if ( TryGetApplicabilityOverTime ( dictionary , "security" , diagnostics , out var security ) )
354+ foreach ( var ( key , action ) in mapping )
369355 {
370- serverlessAvailability . Security = security ;
356+ if ( ! TryGetApplicabilityOverTime ( dictionary , key , diagnostics , out var collection ) )
357+ continue ;
358+ action ( collection ) ;
371359 assigned = true ;
372360 }
373361
@@ -384,99 +372,35 @@ private static bool TryGetProductApplicability(Dictionary<object, object?> dicti
384372 applicability = null ;
385373 var productAvailability = new ProductApplicability ( ) ;
386374 var assigned = false ;
387- if ( TryGetApplicabilityOverTime ( dictionary , "ecctl" , diagnostics , out var ecctl ) )
388- {
389- productAvailability . Ecctl = ecctl ;
390- assigned = true ;
391- }
392-
393- if ( TryGetApplicabilityOverTime ( dictionary , "curator" , diagnostics , out var curator ) )
394- {
395- productAvailability . Curator = curator ;
396- assigned = true ;
397- }
398-
399- if ( TryGetApplicabilityOverTime ( dictionary , "apm_agent_dotnet" , diagnostics , out var apmAgentDotnet ) )
400- {
401- productAvailability . ApmAgentDotnet = apmAgentDotnet ;
402- assigned = true ;
403- }
404-
405- if ( TryGetApplicabilityOverTime ( dictionary , "apm_agent_go" , diagnostics , out var apmAgentGo ) )
406- {
407- productAvailability . ApmAgentGo = apmAgentGo ;
408- assigned = true ;
409- }
410-
411- if ( TryGetApplicabilityOverTime ( dictionary , "apm_agent_java" , diagnostics , out var apmAgentJava ) )
412- {
413- productAvailability . ApmAgentJava = apmAgentJava ;
414- assigned = true ;
415- }
416375
417- if ( TryGetApplicabilityOverTime ( dictionary , "apm_agent_node" , diagnostics , out var apmAgentNode ) )
376+ var mapping = new Dictionary < string , Action < AppliesCollection ? > >
418377 {
419- productAvailability . ApmAgentNode = apmAgentNode ;
420- assigned = true ;
421- }
422-
423- if ( TryGetApplicabilityOverTime ( dictionary , "apm_agent_python" , diagnostics , out var apmAgentPython ) )
424- {
425- productAvailability . ApmAgentPython = apmAgentPython ;
426- assigned = true ;
427- }
428-
429- if ( TryGetApplicabilityOverTime ( dictionary , "apm_agent_ruby" , diagnostics , out var apmAgentRuby ) )
430- {
431- productAvailability . ApmAgentRuby = apmAgentRuby ;
432- assigned = true ;
433- }
434-
435- if ( TryGetApplicabilityOverTime ( dictionary , "apm_agent_rum" , diagnostics , out var apmAgentRum ) )
436- {
437- productAvailability . ApmAgentRum = apmAgentRum ;
438- assigned = true ;
439- }
440-
441- if ( TryGetApplicabilityOverTime ( dictionary , "edot_ios" , diagnostics , out var edotIos ) )
442- {
443- productAvailability . EdotIos = edotIos ;
444- assigned = true ;
445- }
446-
447- if ( TryGetApplicabilityOverTime ( dictionary , "edot_android" , diagnostics , out var edotAndroid ) )
448- {
449- productAvailability . EdotAndroid = edotAndroid ;
450- assigned = true ;
451- }
452-
453- if ( TryGetApplicabilityOverTime ( dictionary , "edot_dotnet" , diagnostics , out var edotDotnet ) )
454- {
455- productAvailability . EdotDotnet = edotDotnet ;
456- assigned = true ;
457- }
458-
459- if ( TryGetApplicabilityOverTime ( dictionary , "edot_java" , diagnostics , out var edotJava ) )
460- {
461- productAvailability . EdotJava = edotJava ;
462- assigned = true ;
463- }
464-
465- if ( TryGetApplicabilityOverTime ( dictionary , "edot_node" , diagnostics , out var edotNode ) )
466- {
467- productAvailability . EdotNode = edotNode ;
468- assigned = true ;
469- }
470-
471- if ( TryGetApplicabilityOverTime ( dictionary , "edot_php" , diagnostics , out var edotPhp ) )
472- {
473- productAvailability . EdotPhp = edotPhp ;
474- assigned = true ;
475- }
476-
477- if ( TryGetApplicabilityOverTime ( dictionary , "edot_python" , diagnostics , out var edotPython ) )
378+ { "ecctl" , a => productAvailability . Ecctl = a } ,
379+ { "curator" , a => productAvailability . Curator = a } ,
380+ { "apm_agent_android" , a => productAvailability . ApmAgentAndroid = a } ,
381+ { "apm_agent_dotnet" , a => productAvailability . ApmAgentDotnet = a } ,
382+ { "apm_agent_go" , a => productAvailability . ApmAgentGo = a } ,
383+ { "apm_agent_ios" , a => productAvailability . ApmAgentIos = a } ,
384+ { "apm_agent_java" , a => productAvailability . ApmAgentJava = a } ,
385+ { "apm_agent_node" , a => productAvailability . ApmAgentNode = a } ,
386+ { "apm_agent_php" , a => productAvailability . ApmAgentPhp = a } ,
387+ { "apm_agent_python" , a => productAvailability . ApmAgentPython = a } ,
388+ { "apm_agent_ruby" , a => productAvailability . ApmAgentRuby = a } ,
389+ { "apm_agent_rum" , a => productAvailability . ApmAgentRum = a } ,
390+ { "edot_ios" , a => productAvailability . EdotIos = a } ,
391+ { "edot_android" , a => productAvailability . EdotAndroid = a } ,
392+ { "edot_dotnet" , a => productAvailability . EdotDotnet = a } ,
393+ { "edot_java" , a => productAvailability . EdotJava = a } ,
394+ { "edot_node" , a => productAvailability . EdotNode = a } ,
395+ { "edot_php" , a => productAvailability . EdotPhp = a } ,
396+ { "edot_python" , a => productAvailability . EdotPython = a }
397+ } ;
398+
399+ foreach ( var ( key , action ) in mapping )
478400 {
479- productAvailability . EdotPython = edotPython ;
401+ if ( ! TryGetApplicabilityOverTime ( dictionary , key , diagnostics , out var collection ) )
402+ continue ;
403+ action ( collection ) ;
480404 assigned = true ;
481405 }
482406
0 commit comments