/// <summary> /// Executes this modification. /// </summary> public bool Execute(IVariantResolver inResolver, object inContext = null, IMethodCache inInvoker = null) { Variant operandValue; if (Operand.TryResolve(inResolver, inContext, out operandValue, inInvoker)) { return(inResolver.TryModify(inContext, VariableKey, Operator, operandValue)); } return(false); }
/// <summary> /// Evaluates this comparison. /// </summary> public bool Evaluate(IVariantResolver inResolver, object inContext = null, IMethodCache inInvoker = null) { Variant leftValue, rightValue; bool bRetrievedLeft = Left.TryResolve(inResolver, inContext, out leftValue, inInvoker); bool bRetrievedRight = Right.TryResolve(inResolver, inContext, out rightValue, inInvoker); switch (Operator) { case VariantCompareOperator.LessThan: return(leftValue < rightValue); case VariantCompareOperator.LessThanOrEqualTo: return(leftValue <= rightValue); case VariantCompareOperator.EqualTo: return(leftValue == rightValue); case VariantCompareOperator.NotEqualTo: return(leftValue != rightValue); case VariantCompareOperator.GreaterThanOrEqualTo: return(leftValue >= rightValue); case VariantCompareOperator.GreaterThan: return(leftValue > rightValue); case VariantCompareOperator.Exists: return(bRetrievedLeft); case VariantCompareOperator.DoesNotExist: return(!bRetrievedLeft); case VariantCompareOperator.True: return(leftValue.AsBool()); case VariantCompareOperator.False: return(!leftValue.AsBool()); default: throw new InvalidOperationException("Unknown operator " + Operator.ToString()); } }