Sage Modeling and Simulation Library

EvaluatorFactory Class

The Evaluator Factory creates objects that can evaluate expressions provided by the caller. First an expression is provided and compiled into an object that can evaluate it - that object is passed back as an Evaluator delegate. Then later the Evaluator delegate is called with the values appropriate to the variables that are a part of the pre-provided expression. The result of this evaluation is the (double) value that is computed.
The body of the evaluator can be any compilable statement. If the evaluator is to return a value, the body must assign that value to the (predefined) variable "Result".
The ArgNames array is an array of strings that contain the names of the arguments to the evaluation of the expression. The defaults of those argNames is:

{"PA","PB","PC","PD","PE","PF","PG","PH","PJ","PK","RA","RB","RC","RD","RE","RF","RG","RH","RJ","RK"};

An example of using this class might be as follows:

C#
Evaluator eval = EvaluatorFactory.CreateEvaluator("Result = RA+(RB/RC);",new string[]{"RA","RB","RC"});
...and this eval could later be called with:
C#
_Debug.WriteLine(eval(3.0,4.0,5.0));
which would result in 3.8 being written to the Trace.

Namespace:  Highpoint.Sage.SimCore
Assembly:  Sage4 (in Sage4.dll)

Syntax


public static class EvaluatorFactory

Inheritance Hierarchy


Object
  Highpoint.Sage.SimCore..::..EvaluatorFactory