Beispiel #1
0
        private ConditionExpression TryParseComparaisonOperator()
        {
            int  i     = 0;
            bool flag  = false;
            bool flag2 = false;
            ConditionExpression result;

            while (i < this.String.Length)
            {
                if (this.String[i] == '"')
                {
                    flag = !flag;
                    i++;
                }
                else
                {
                    if (this.String[i] == '(')
                    {
                        flag2 = true;
                        i++;
                    }
                    else
                    {
                        if (this.String[i] == ')')
                        {
                            flag2 = false;
                            i++;
                        }
                        else
                        {
                            if (flag || flag2)
                            {
                                i++;
                            }
                            else
                            {
                                ComparaisonOperatorEnum?comparaisonOperatorEnum = Criterion.TryGetOperator(this.String[i]);
                                if (!comparaisonOperatorEnum.HasValue)
                                {
                                    i++;
                                }
                                else
                                {
                                    if (i + 1 >= this.String.Length)
                                    {
                                        throw new System.Exception(string.Format("Cannot parse {0} :  Right Expression of comparaison operator index {1} is empty", this.String, i));
                                    }
                                    string text = this.String.Substring(0, i);
                                    if (string.IsNullOrEmpty(text))
                                    {
                                        throw new System.Exception(string.Format("Cannot parse {0} : Left Expression of comparaison operator index {1} is empty", this.String, i));
                                    }
                                    Criterion criterion = Criterion.CreateCriterionByName(text);
                                    string    text2     = this.String.Substring(i + 1, this.String.Length - (i + 1));
                                    if (string.IsNullOrEmpty(text2))
                                    {
                                        throw new System.Exception(string.Format("Cannot parse {0} : Right Expression of comparaison operator index {1} is empty", this.String, i));
                                    }
                                    criterion.Literal  = text2;
                                    criterion.Operator = comparaisonOperatorEnum.Value;
                                    criterion.Build();
                                    result = criterion;
                                    return(result);
                                }
                            }
                        }
                    }
                }
            }
            result = null;
            return(result);
        }