Click or drag to resize

CSScriptEvaluator Property

Global instance of the generic IEvaluator. This object is to be used for dynamic loading of the C# code by "compiler as service" based on the Engine value.

Generic IEvaluator interface provides a convenient way of accessing compilers without 'committing' to a specific compiler technology (e.g. Mono, Roslyn, CodeDOM). This may be required during troubleshooting or performance tuning.

Switching between compilers can be done via global CSScript.Engine.

Remarks
By default CSScript.Evaluator always returns a new instance of IEvaluator. If this behavior is undesired change the evaluator access policy by setting EvaluatorConfig.Access value.

Namespace:  CSScriptLib
Assembly:  CSScriptLib (in CSScriptLib.dll) Version: 1.3.2.0
Syntax
C#
public static IEvaluator Evaluator { get; }

Property Value

Type: IEvaluator
The IEvaluator instance.
Examples
if(testingWithMono)
    CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono;
else
    CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn;

var sub = CSScript.Evaluator
                  .LoadDelegate<Func<int, int, int>>(
                              @"int Sub(int a, int b) {
                                    return a - b;
                                }");
See Also