Nevron .NET Vision
Nevron.FormulaEngine Namespace / NFormulaEngine Class

In This Topic
    NFormulaEngine Class
    In This Topic
    The NFormulaEngine class is used for the runtime parsing and evaluation of formula expressions.
    Object Model
    NFormulaEngine Class
    Public Class NFormulaEngine 
    Dim instance As NFormulaEngine
    public class NFormulaEngine 
    A formula expression is string, which can be evaluated to a single variant value. A valid formula expression is composed by elements of one of the following types.

    • Numbers These are integer and floating point numbers. For example: 12, 0.1, 145.23, 7.5E-17, 8.234E+13 etc.
    • Boolean values These are the true and false boolean constants, which in the expression can be represented by the following strings: true, false, True, False, TRUE and FALSE
    • Strings In the formula expression, strings must are enclosed in " characters. For example: "hello", "world" etc.
    • Operators Supported is a common set of binary and unary operators. For example: +, -, *. /, = etc.
    • Parenthesis The '(' and ')' characters can used to change the operators priviledge.
    • Functions Supported is a large set of mathematical, logical, string, bitwise and date-time functions. For example: MIN, MAX, SIN, COS etc. Function arguments must be enclosed in parenthesis and divided by commas.
    • Variables The recognized set of variables is defined by the NVariableCollection class accessible from the Variables property.
    • References Any identifiter, which cannot be classified as a function or variable name, is a potential reference element. Reference elements are identified by the DelegateIsReferenceName delegate for which you must subscribe. If a token is identified as a reference, its value must be provided by the DelegateGetReferenceValue delegate.

    The following example evaluates a formula expression: // create the formula engine NFormulaEngine engine = new NFormulaEngine(); // define the a and b variables engine.Variables.Add("a", new NVariant(10)); engine.Variables.Add("b", new NVariant(20)); // evaluate an expression (evaluates to 50) NVariant result = engine.ParseAndEvaluate("a + b * 2");
    Inheritance Hierarchy



    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also