コード例 #1
0
        CreateLogicPair(IParseTreeValue value, string opSymbol, IParseTreeValueFactory factory)
        {
            var operands = value.Token.Split(new string[] { opSymbol }, StringSplitOptions.None);

            if (operands.Count() == 2)
            {
                var lhs = factory.Create(operands[0].Trim());
                var rhs = factory.Create(operands[1].Trim());
                if (opSymbol.Equals(Tokens.Like))
                {
                    rhs = factory.CreateDeclaredType($"\"{rhs.Token}\"", Tokens.String);
                }
                return(lhs, rhs);
            }

            if (operands.Count() == 1)
            {
                var lhs = factory.Create(operands[0].Trim());
                return(lhs, null);
            }
            return(null, null);
        }
コード例 #2
0
        private IParseTreeValue EvaluateLogicalNot(IParseTreeValue parseTreeValue)
        {
            var opProvider = new OperatorTypesProvider(parseTreeValue.ValueType, LogicalOperators.NOT);

            if (!parseTreeValue.ParsesToConstantValue)
            {
                //Unable to resolve to a value, return an expression
                var opType = opProvider.OperatorDeclaredType;
                opType = opType.Equals(string.Empty) ? Tokens.Variant : opProvider.OperatorDeclaredType;
                return(_valueFactory.CreateExpression($"{LogicalOperators.NOT} {parseTreeValue.Token}", opType));
            }

            var value = parseTreeValue.AsLong();

            return(_valueFactory.CreateDeclaredType((~value).ToString(CultureInfo.InvariantCulture), opProvider.OperatorDeclaredType));
        }