public static bool ParseAndEvaluate(string condition, Project context) { if (String.IsNullOrEmpty(condition)) { return(true); } try { ConditionExpression ce = ParseCondition(condition); if (!ce.CanEvaluateToBool(context)) { throw new InvalidProjectFileException(String.Format("Can not evaluate \"{0}\" to bool.", condition)); } return(ce.BoolEvaluate(context)); } catch (ExpressionParseException epe) { throw new InvalidProjectFileException( String.Format("Unable to parse condition \"{0}\" : {1}", condition, epe.Message), epe); } catch (ExpressionEvaluationException epe) { throw new InvalidProjectFileException( String.Format("Unable to evaluate condition \"{0}\" : {1}", condition, epe.Message), epe); } }
public override bool BoolEvaluate(Project context) { if (left.CanEvaluateToNumber(context) && right.CanEvaluateToNumber(context)) { float l, r; l = left.NumberEvaluate(context); r = right.NumberEvaluate(context); return(NumberCompare(l, r, op)); } else if (left.CanEvaluateToBool(context) && right.CanEvaluateToBool(context)) { bool l, r; l = left.BoolEvaluate(context); r = right.BoolEvaluate(context); return(BoolCompare(l, r, op)); } else { string l, r; l = left.StringEvaluate(context); r = right.StringEvaluate(context); return(StringCompare(l, r, op)); } }
public override bool BoolEvaluate(Project context) { if (!left.BoolEvaluate(context)) { return(false); } if (!right.BoolEvaluate(context)) { return(false); } return(true); }
public override bool BoolEvaluate(IExpressionContext context) { if (left.BoolEvaluate(context)) { return(true); } if (right.BoolEvaluate(context)) { return(true); } return(false); }
public bool Execute() { if (Condition == String.Empty) { Evaluate(project, true); } else { ConditionExpression ce = ConditionParser.ParseCondition(Condition); Evaluate(project, ce.BoolEvaluate(project)); } return(true); }
public static bool ParseAndEvaluate(string condition, IExpressionContext context) { if (String.IsNullOrEmpty(condition)) { return(true); } ConditionExpression ce = ParseCondition(condition); if (!ce.CanEvaluateToBool(context)) { throw new Exception(String.Format("Can not evaluate \"{0}\" to bool.", condition)); } return(ce.BoolEvaluate(context)); }
internal void Evaluate() { if (evaluated) { return; } foreach (BuildItem bi in buildItems) { if (bi.Condition == String.Empty) { bi.Evaluate(parentProject, true); } else { ConditionExpression ce = ConditionParser.ParseCondition(bi.Condition); bi.Evaluate(parentProject, ce.BoolEvaluate(parentProject)); } } evaluated = true; }
public override bool BoolEvaluate(Project context) { return(!(expression.BoolEvaluate(context))); }