示例#1
0
    private static ICondition?ReadBetweenCondition(IConditionKeyword operand, bool negated, IWordReader reader, List <string> messages)
    {
        var min = ReadNextKeyword(reader, messages);

        if (min is null)
        {
            return(null);
        }

        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType != WordType.And)
        {
            messages.Add(string.Format(BetweenWithoutAnd, reader.Word));
            return(null);
        }

        var max = ReadNextKeyword(reader, messages);

        if (max is null)
        {
            return(null);
        }

        if (negated)
        {
            return(new NotBetweenCondition(operand, min, max));
        }

        return(new BetweenCondition(operand, min, max));
    }
示例#2
0
    private static ICondition?ReadNullCondition(IConditionKeyword operand, IWordReader reader, List <string> messages)
    {
        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType == WordType.Null)
        {
            return(new IsNullCondition(operand));
        }

        if (reader.WordType != WordType.Not)
        {
            messages.Add(string.Format(InvalidTokenAfterIs, reader.Word));
            return(null);
        }

        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType == WordType.Null)
        {
            return(new IsNotNullCondition(operand));
        }

        messages.Add(string.Format(InvalidTokenAfterIsNot, reader.Word));
        return(null);
    }
示例#3
0
    private static ICondition?ReadInCondition(IConditionKeyword operand, bool negated, IWordReader reader, List <string> messages)
    {
        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType != WordType.OpenParenthesys)
        {
            messages.Add(string.Format(InvalidTokenAfterIn, reader.Word));
            return(null);
        }

        var values = new List <IConditionKeyword>();
        IConditionKeyword?value;

        for (; ;)
        {
            value = ReadNextKeyword(reader, messages);
            if (value is null)
            {
                return(null);
            }
            values.Add(value);

            if (!ReadExpectingNotBeTheEnd(reader, messages))
            {
                return(null);
            }

            if (reader.WordType == WordType.CloseParenthesys)
            {
                break;
            }

            if (reader.WordType != WordType.Comma)
            {
                messages.Add(string.Format(InvalidTokenAfterInValue, reader.Word));
                return(null);
            }
        }

        if (negated)
        {
            return(new NotInCondition(operand, values));
        }

        return(new InCondition(operand, values));
    }
示例#4
0
    private static ICondition?ReadOperator(
        IWordReader reader,
        List <string> messages,
        IConditionKeyword left,
        Func <IConditionKeyword, IConditionKeyword, ICondition> factory
        )
    {
        var right = ReadNextKeyword(reader, messages);

        if (right is null)
        {
            return(null);
        }
        return(factory.Invoke(left, right));
    }
示例#5
0
    private static ICondition?ReadNotOperator(
        IWordReader reader,
        List <string> messages,
        IConditionKeyword left
        )
    {
        if (!ReadExpectingNotBeTheEnd(reader, messages))
        {
            return(null);
        }

        if (reader.WordType == WordType.In)
        {
            return(ReadInCondition(left, true, reader, messages));
        }

        if (reader.WordType == WordType.Between)
        {
            return(ReadBetweenCondition(left, true, reader, messages));
        }

        messages.Add(string.Format(InvalidTokenAfterNot, reader.Word));
        return(null);
    }
示例#6
0
 public BetweenCondition(IConditionKeyword operand, IConditionKeyword min, IConditionKeyword max)
 {
     Operand = operand;
     Min     = min;
     Max     = max;
 }
示例#7
0
 public ComparisonConditionBase(IConditionKeyword left, IConditionKeyword right)
 {
     Left  = left;
     Right = right;
 }
示例#8
0
 public NotEqualsToCondition(IConditionKeyword left, IConditionKeyword right) : base(left, right)
 {
 }
示例#9
0
 public IsNotNullCondition(IConditionKeyword operand) => Operand = operand;
示例#10
0
 public InCondition(IConditionKeyword operand, IEnumerable <IConditionKeyword> values)
 {
     Operand = operand;
     Values  = values;
 }
示例#11
0
 public GreaterThanCondition(IConditionKeyword left, IConditionKeyword right) : base(left, right)
 {
 }
示例#12
0
 public EqualOrLowerThanCondition(IConditionKeyword left, IConditionKeyword right) : base(left, right)
 {
 }