Ejemplo n.º 1
0
        internal override ExValue Evaluate <TKey>(TagBatchInstance <TKey> instance)
        {
            ExValue left  = LeftHand.Evaluate(instance);
            ExValue right = RightHand.Evaluate(instance);

            switch (Token.TokenType)
            {
            case TagTokenType.IsEqual:
                return(new ExValue(left.Equals(right)));

            case TagTokenType.IsNot:
                return(new ExValue(!left.Equals(right)));

            case TagTokenType.IsLte:
                return(new ExValue(left.CompareTo(right) <= 0));

            case TagTokenType.IsLessThan:
                return(new ExValue(left.CompareTo(right) < 0));

            case TagTokenType.IsGreaterThan:
                return(new ExValue(left.CompareTo(right) > 0));

            case TagTokenType.IsGte:
                return(new ExValue(left.CompareTo(right) >= 0));

            default:
                throw new InvalidOperationException();
            }
        }
Ejemplo n.º 2
0
        internal override ExValue Evaluate <TKey>(TagBatchInstance <TKey> instance)
        {
            ExValue leftValue  = LeftHand.Evaluate(instance);
            bool    leftResult = leftValue.ToBool();

            if (IsAnd != leftResult)
            {
                // ((IsAnd && !leftResult) || (IsOr && leftResult))
                return(leftValue);
            }

            return(RightHand.Evaluate(instance));
        }