private IEnumerable<ConditionEvaluation> EvaluateItemConditions(IHaveFilterConditions currentItem, IDictionary<string, string> runtimeContext, IEnumerable<IHaveFilterConditions> items)
 {
     foreach (KeyValuePair<string, string> runtimeContextItem in runtimeContext)
     {
         foreach (var condition in currentItem.FilterConditions)
         {
             var evalContext = new ConditionEvaluationContext(runtimeContextItem, runtimeContext, items);
             var relationToContext = EvaluateCondition(evalContext, condition);
             yield return new ConditionEvaluation(relationToContext, evalContext, condition);
         }
     }
 }
        private RelationToContextEnum EvaluateCondition(ConditionEvaluationContext context, IFilterCondition condition)
        {
            if (condition.Subject == context.CurrentRuntimeContextItem.Key)
            {
                bool evaluationResult = condition.Evaluate(context);
                if (condition.Negate)
                {
                    evaluationResult = !evaluationResult;
                }

                return evaluationResult ? RelationToContextEnum.True : RelationToContextEnum.False;
            }

            return RelationToContextEnum.Neutral;
        }
Beispiel #3
0
 public ConditionEvaluation(RelationToContextEnum relationToContext, ConditionEvaluationContext context, IFilterCondition condition)
 {
     RelationToContext = relationToContext;
     Context = context;
     Condition = condition;
 }
Beispiel #4
0
 public bool Evaluate(ConditionEvaluationContext context)
 {
     return context.CurrentRuntimeContextItem.Key == Subject && context.CurrentRuntimeContextItem.Value == Value;
 }