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); }
protected void ValidateBase(ExprOperator exprOperator) { this.ValidateBase((ExprItem)exprOperator); Invariant(exprOperator.Operator != null, string.Format(CommonStrings.XMustNotBeNull, "ExprOperator.Operator")); this.Validate(exprOperator.Operator); }
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); }
private string GetNameCodeCriteria() { if (this.Predicates == null || this.Predicates.Count == 0) { return(null); } foreach (PredicateExpr predicateExpr in this.Predicates) { ExprOperator predicate = predicateExpr.Predicate; if (predicate == null) { throw new ApplicationException("predicate must not be null."); } string nameValue = GetValueCriteriaByPath(predicate, "name/defining_code/code_string"); if (nameValue != null) { return(nameValue); } } return(null); }
protected void Validate(ExprOperator exprOperator) { if (exprOperator == null) { throw new ArgumentNullException( string.Format(CommonStrings.XIsNull, "exprOperator")); } const string methodName = "Validate"; try { System.Reflection.MethodInfo method = this.GetType().GetMethod(methodName, System.Reflection.BindingFlags.ExactBinding | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, Type.DefaultBinder, new Type[] { exprOperator.GetType() }, new System.Reflection.ParameterModifier[0]); if (method != null) { if (method != lastExprOperatorMethod || exprOperator != lastExprOperator) { lastExprOperatorMethod = method; lastExprOperator = exprOperator; method.Invoke(this, new Object[] { exprOperator }); } else { string message = string.Format(CommonStrings.LoopingMethodTerminated, methodName, exprOperator.GetType().ToString()); System.Diagnostics.Debug.WriteLine(message); throw new ApplicationException(message); } } else { string message = string.Format(CommonStrings.MethodXNotImplementedForParamTypeY, methodName, exprOperator.GetType().ToString()); System.Diagnostics.Debug.WriteLine(message); throw new ApplicationException(message); } } catch (Exception ex) { if (ex.InnerException != null) { if (ex.InnerException is ApplicationException && ex.InnerException.InnerException != null && ex.InnerException.Message == ex.InnerException.InnerException.Message) { throw new ApplicationException(ex.InnerException.Message, ex.InnerException.InnerException); } else { throw new ApplicationException(ex.InnerException.Message, ex.InnerException); } } else { throw new ApplicationException(ex.Message, ex); } } }
internal PredicateExpr(ExprOperator predicate) { this.predicate = predicate; }