Example #1
0
        private static ExprBinaryOperator ProcessStandardPredicateExpr(Match match)
        {
            string standardExpr = match.Groups["predicate_expre"].Value;

            if (string.IsNullOrEmpty(standardExpr))
            {
                throw new ApplicationException("standardExpr must not be null or empty.");
            }

            string path = match.Groups["predicate_path"].Value;

            if (string.IsNullOrEmpty(path))
            {
                throw new ApplicationException("predicate_path must not be null or empty");
            }

            ExprLeaf     lefOperand           = new ExprLeaf(path, "String", "Path");
            string       standardExprOperator = match.Groups["predicate_path_operator"].Value;
            OperatorKind operatorKind         = new OperatorKind(OperatorKind.GetOperatorKind(standardExprOperator));

            // default value
            object             criteriaValue  = null;
            string             type           = GetCriteriaType(match, out criteriaValue);
            ExprLeaf           rightOperand   = new ExprLeaf(criteriaValue, type, "constraint");
            ExprBinaryOperator binaryOperator = new ExprBinaryOperator(lefOperand, rightOperand, type, operatorKind, false);

            return(binaryOperator);
        }
Example #2
0
        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);
        }
Example #3
0
        private static ExprBinaryOperator ProcessBoolExpr(Match match)
        {
            string boolExprString = match.Groups["genericExpr"].Value;

            if (string.IsNullOrEmpty(boolExprString))
            {
                throw new ApplicationException("boolExprString must not be null or empty.");
            }

            ExprBinaryOperator boolExpr          = null;
            string             leftOperandString = match.Groups["leftSimpleExpr"].Value;

            if (string.IsNullOrEmpty(leftOperandString))
            {
                throw new ApplicationException("leftOperandString must not be null or empty.");
            }

            ExprOperator leftOperand = ToExprOperator(leftOperandString);

            do
            {
                if (boolExpr != null)
                {
                    leftOperand = boolExpr;
                }

                string       boolOperatorStr = match.Groups["predicate_bool_operator"].Value;
                OperatorKind boolOperator    = new OperatorKind(OperatorKind.GetOperatorKind(boolOperatorStr));
                string       rightOperandStr = match.Groups["rightSimpleExpr"].Value;
                if (string.IsNullOrEmpty(rightOperandStr))
                {
                    throw new ApplicationException("rightOperandStr must not be null or empty.");
                }

                ExprOperator rightOperand = ToExprOperator(rightOperandStr);
                boolExpr = new ExprBinaryOperator(leftOperand, rightOperand, "Boolean", boolOperator, false);

                match = match.NextMatch();
            } while (match.Success);

            DesignByContract.Check.Ensure(boolExpr != null, "boolExpr must not be null.");

            return(boolExpr);
        }