public void Execute(ExecutionState state) { foreach (ExecutionPath ep in executionPaths) { object o = true; if (ep.Condition != null) { o = TokenParser.ReduceFromExpression(state, instructionToken, ep.Condition.Evaluate(state, ep.Token)); } if (BooleanExpression.True.Equals(o)) { ep.Instructions.Execute(state); return; } } }
protected override object Evaluate(IExpression left, IExpression right, ExecutionState state) { object b = TokenParser.VerifyUnderlyingType(TokenParser.ReduceFromExpression(state, token, right.Evaluate(state, token))); object a = TokenParser.VerifyUnderlyingType(TokenParser.ReduceFromExpression(state, token, left.Evaluate(state, token))); if (a == null || b == null) { if (a == null || b == null) { return(true); } else { return(false); } } if ((a is decimal && b is string) || (a is string && b is decimal)) { decimal k, m; bool result; if (a is decimal && b is string) { k = (decimal)a; result = decimal.TryParse((string)b, out m); } else { k = (decimal)b; result = decimal.TryParse((string)a, out m); } if (result) { return(k.Equals(m)); } } return(a.Equals(b) || b.Equals(a)); // we check both sides in case one side has overridden the Equals method }