Table of Contents

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
  • Imported namespaces
    • By default, the following namespaces are imported, but additional namespaces can be added via AddImport(string):
      • System
      • System.Linq
  • 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

ExpressionEnvironment

Methods

AddImport(string)

Adds a namespace import to the expression environment.

public void AddImport(string import)

Parameters

import string

The 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 Assembly

The 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 string

The 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.