Culture Sensitive Expressions

Flee allows you to specify the culture used to parse expressions. This lets you enter expressions that use numbers in the format of a particular culture and have them be correctly parsed into an expression.

When the parse culture is set, Flee will use the CultureInfo.NumberFormat.NumberDecimalSeparator as the decimal point for real numbers and the CultureInfo.TextInfo.ListSeparator as the function argument separator.

The following example shows how to set this up:

// Set the culture of Flee's parser
CultureInfo ci = new CultureInfo("fr-FR");            

ExpressionContext context = new ExpressionContext();
context.ParseCulture = ci
// Create an expression that uses numbers in the culture's format
IDynamicExpression e = context.CompileDynamic("round(100,75; 1)");
object result = e.Evaluate();

Last edited Nov 9, 2008 at 10:00 PM by ECiloci, version 5


No comments yet.