private static ExprBinaryOperator ProcessPredicateWithFullPath(Match match) { string fullPath = match.Groups["fullPath"].Value; if (string.IsNullOrEmpty(fullPath)) { throw new ApplicationException("fullPath must not be null or empty."); } PathExpr pathExpr = ToPathExpr(fullPath); string standardExprOperator = match.Groups["predicate_path_operator"].Value; OperatorKind operatorKind = new OperatorKind(OperatorKind.GetOperatorKind(standardExprOperator)); string predicateCriteria = match.Groups["predicate_criteria"].Value; if (string.IsNullOrEmpty(predicateCriteria)) { throw new ApplicationException("predicateCriteria must not be null or empty."); } object criteriaValue = null; string type = GetCriteriaType(match, out criteriaValue); ExprLeaf rightOperand = new ExprLeaf(criteriaValue, type, "constraint"); ExprBinaryOperator binaryOperator = new ExprBinaryOperator(pathExpr, rightOperand, type, operatorKind, false); return(binaryOperator); }
internal string GetPredicateFullPath(ExprItem exprItem) { ExprLeaf leaf = exprItem as ExprLeaf; if (leaf != null) { if (leaf.ReferenceType.IndexOf("path", StringComparison.InvariantCultureIgnoreCase) >= 0) { return(leaf.Item.ToString()); } } ExprUnaryOperator unarayOperand = exprItem as ExprUnaryOperator; if (unarayOperand != null) { ExprItem operand = unarayOperand.Operand; return(GetPredicateFullPath(operand)); } PathExpr pathExpr = exprItem as PathExpr; if (pathExpr != null) { return(pathExpr.Path); } return(null); }
private static PathExpr ToPathExpr(string pathString) { MatchCollection matchCollection = Regex.Matches(pathString, PathPartPattern, RegexOptions.Compiled | RegexOptions.Singleline); List <PathStep> pathSteps = new List <PathStep>(); PathStep precedingStep = null; foreach (Match stepMatch in matchCollection) { List <PredicateExpr> predicateExprs = null; CaptureCollection predicateCaptures = stepMatch.Groups["predicate"].Captures; foreach (Capture capture in predicateCaptures) { if (predicateExprs == null) { predicateExprs = new List <PredicateExpr>(); } string predicateExprString = capture.Value; ExprOperator predicate = ToExprOperator(predicateExprString); PredicateExpr predicateExpr = new PredicateExpr(predicate); predicateExprs.Add(predicateExpr); } PathStep thisStep = new PathStep(stepMatch, precedingStep, predicateExprs); pathSteps.Add(thisStep); precedingStep = thisStep; } PathExpr pathExpr = new PathExpr(pathString, pathSteps); return(pathExpr); }