예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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());
            }
        }