/// <summary> /// Evaluates the given constant attribute expression to a list of integer values. /// </summary> /// <param name="expression">The expression to be evaluated.</param> /// <returns>The list of integer values.</returns> public IList<int?> EvaluateConstant(string expression) { EnterContext(); // hide symbols so we only see constants MultipleExpressionEvaluator evaluator = new MultipleExpressionEvaluator(this, expression); IList<object> result = evaluator.Evaluate(); ExitContext(); IList<int?> intResult = new List<int?>(); foreach (object s in result) { intResult.Add(s as int?); } return intResult; }
/// <summary> /// Evaluates the given attribute expression to a set of integer value by using the current /// context for symbol resolution. /// </summary> /// <param name="expression">The expression to be evaluated.</param> /// <returns>The value list for the expression.</returns> public IList<int?> EvaluateMultipleExpressions(string expression) { MultipleExpressionEvaluator evaluator = new MultipleExpressionEvaluator(this, expression); IList<object> result = evaluator.Evaluate(); if (result.Count == 0) TestAssertFail("expected at least one expression in attribute '{0}'", expression); IList<int?> intResult = new List<int?>(); foreach (object s in result) { intResult.Add(s as int?); } return intResult; }
/// <summary> /// Evaluates the given attribute expression to an integer value by using the current /// context for symbol resolution. /// </summary> /// <param name="expression">The expression to be evaluated.</param> /// <returns>The value for the expression.</returns> public int Evaluate(string expression) { MultipleExpressionEvaluator evaluator = new MultipleExpressionEvaluator(this, expression); IList<object> result = evaluator.Evaluate(); if (result.Count != 1 || result[0] == null) TestAssertFail("expected exactly one expression in attribute '{0}'", expression); return (int)result[0]; }