/// <summary> /// Builds up a constant expression that consists of the value that is mapped to the specified value. /// </summary> /// <param name="current">The expression that represents the current element of the collection.</param> /// <param name="value">The evaluatee.</param> /// <returns>The constant expression that consists of the value that is mapped to the specified value.</returns> public override Operand Evaluate(Expression current, string value) { Logger.Info("Evaluating the specified value '{0}'.", value ?? "null"); if (value == null) { throw new ArgumentNullException("value"); } if (!evaluators.ContainsKey(value.ToUpperInvariant())) { Logger.Verbose("Ignored the specified value because this didn't match any registered variable names."); return(null); } var eval = evaluators[value.ToUpperInvariant()]; Logger.Verbose("Evaluated as '{0} : {1}'.", eval.ToString(), eval.GetType().FullName); return(builder.BuildUp(eval())); }
/// <summary> /// Builds up a constant expression that consists of the value that is mapped to the specified value. /// </summary> /// <param name="current">The expression that represents the current element of the collection.</param> /// <param name="value">The evaluatee.</param> /// <returns>The constant expression that consists of the value that is mapped to the specified value.</returns> public override Operand Evaluate(Expression current, string value) { Logger.Info("Evaluating the specified value '{0}'.", value ?? "null"); if (value == null) { throw new ArgumentNullException("value"); } foreach (var eval in evaluators) { var match = eval.Key.Match(value); if (match.Success) { var result = eval.Value(match); Logger.Verbose("Evaluated as '{0} : {1}'.", result.ToString(), result.GetType().FullName); return(builder.BuildUp(result)); } } Logger.Verbose("Ignored the specified value because this didn't match any registered patterns."); return(null); }