private static string EvalExpression(ExpressionParser parser, TemplateToken token, TemplateParserContext context) { char q = token.TokenId == TokenID.ExpressionNew ? '`' : ':'; int quoteIdx = token.Text.LastIndexOf(q); string expr = quoteIdx >= 0 ? token.Text.Substring(0, quoteIdx).Trim() : token.Text; IValueWithType result = parser.Evaluate(expr, context, token.TokenPosition); if (token.TokenType == TemplateTokenType.Statement) { return(""); } if (result.Value is Control) { return(context.View.ParseTranslations(((Control)result.Value).Render(context.View))); } string fmt = quoteIdx >= 0 ? token.Text.Substring(quoteIdx + 1).Trim() : null; if (fmt != null) { return(String.Format(WebAppConfig.FormatProvider, "{0:" + fmt + "}", result.Value)); } else if (result.Value is string) { return((string)result.Value); } else { return(result.Value == null ? "" : Convert.ToString(result.Value, WebAppConfig.FormatProvider)); } }
public object Evaluate(string s, out Type type, IParserContext context, TokenPosition tokenPosition) { IValueWithType value = ParseWithContext(s, context, tokenPosition).Evaluate(); type = value.Type; return(value.Value); }
public object Evaluate(string s, out Type type) { IValueWithType value = ParseWithContext(s).Evaluate(); type = value.Type; return(value.Value); }
public void Set(string name, IValueWithType data) { Set(name, data.Value, data.Type); }
public void SetLocal(string name, IValueWithType data) { this.SetLocal(name, data.Value, data.Type); }