Class ExpressionEnvironment
- Namespace
- Acuit.Pinpoint.Workflows.Expressions
- Assembly
- Acuit.Pinpoint.Workflows.dll
An environment within which expressions are compiled.
public class ExpressionEnvironment
- Inheritance
-
ExpressionEnvironment
- Inherited Members
Remarks
The expression environment provides the following for C# expressions:
- Assembly references
- Custom assemblies can be added via AddReference(Assembly).
- Imported namespaces
- By default, the following namespaces are imported, but additional namespaces can be added via AddImport(string):
- System
- System.Linq
- By default, the following namespaces are imported, but additional namespaces can be added via AddImport(string):
- Global properties
- See IExpressionGlobals for the available global properties.
It uses this environment to compile C# expressions via CreateCSharpScriptRunner<TValue>(string).
Properties
Instance
Gets the single, shared ExpressionEnvironment instance which is used for the executing process.
public static ExpressionEnvironment Instance { get; }
Property Value
Methods
AddImport(string)
Adds a namespace import to the expression environment.
public void AddImport(string import)
Parameters
import
stringThe namespace to import.
Remarks
If the namespace has previously already been imported, it will not be added again.
Exceptions
- ArgumentNullException
import
is null.
AddReference(Assembly)
Adds an assembly reference to the expression environment.
public void AddReference(Assembly assembly)
Parameters
assembly
AssemblyThe assembly.
Remarks
If the assembly reference has previously already been added, it will not be added again.
Exceptions
- ArgumentNullException
assembly
is null.
CreateCSharpScriptRunner<TValue>(string)
Creates a script runner for a C# expression.
[CLSCompliant(false)]
public ScriptRunner<TValue> CreateCSharpScriptRunner<TValue>(string code)
Parameters
code
stringThe C# expression.
Returns
- ScriptRunner<TValue>
The script runner, which is a delegate that will run the compiled code when invoked.
Type Parameters
TValue
The C# expression return type.
Remarks
Duplicate C# expressions (both in their code and environment settings) are cached and reused.
Exceptions
- ArgumentNullException
code
is null.