in src/Analyzer.JsonRuleEngine/Expressions/StructuredExpression.cs [46:75]
public override IEnumerable<JsonRuleEvaluation> Evaluate(IJsonPathResolver jsonScope, ISourceLocationResolver jsonLineNumberResolver)
{
return EvaluateInternal(jsonScope, scope =>
{
List<JsonRuleEvaluation> jsonRuleEvaluations = new List<JsonRuleEvaluation>();
bool? evaluationPassed = null;
foreach (var expression in Expressions)
{
foreach (var evaluation in expression.Evaluate(scope, jsonLineNumberResolver))
{
// Add evaluations if scopes were found to evaluate
if (evaluation.HasResults)
{
evaluationPassed = !evaluationPassed.HasValue
// if no value, this is the first expression evaluated so set the inital value of result
? evaluation.Passed
// otherwise use defined operation to calculate intermediate expression result
: Operation(evaluationPassed.Value, evaluation.Passed);
jsonRuleEvaluations.Add(evaluation);
}
}
}
evaluationPassed |= jsonRuleEvaluations.Count == 0;
return new JsonRuleEvaluation(this, evaluationPassed.Value, jsonRuleEvaluations);
});
}