private ConditionExpression TryParseComparaisonOperator() { int index = 0; bool inQuote = false; bool inParenthese = false; while (index < String.Length) { if (String[index] == '\"') { inQuote = !inQuote; index++; continue; } if (String[index] == '(') { inParenthese = true; index++; continue; } if (String[index] == ')') { inParenthese = false; index++; continue; } if (inQuote || inParenthese) { index++; continue; } var op = Criterion.TryGetOperator(String[index]); if (op != null) { if (index + 1 >= String.Length) { throw new Exception(string.Format("Cannot parse {0} : Right Expression of comparaison operator index {1} is empty", String, index)); } var leftStr = String.Substring(0, index); if (string.IsNullOrEmpty(leftStr)) { throw new Exception(string.Format("Cannot parse {0} : Left Expression of comparaison operator index {1} is empty", String, index)); } var criterion = Criterion.CreateCriterionByName(leftStr); var rightStr = String.Substring(index + 1, String.Length - (index + 1)); if (string.IsNullOrEmpty(rightStr)) { throw new Exception(string.Format("Cannot parse {0} : Right Expression of comparaison operator index {1} is empty", String, index)); } criterion.Literal = rightStr; criterion.Operator = op.Value; criterion.Build(); return(criterion); } index++; } return(null); }
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); }