Assembly: OptimaJet.Workflow.Core

Class ExpressionsCompiler

OptimaJet.Workflow.Core.CodeActions.ExpressionsCompiler

Prepares and compiles transition expression conditions and subprocess-name values into asynchronous delegates evaluated against ProcessInstance objects.

public static class ExpressionsCompiler

Properties

public static IExternalExpressionsCompiler ExternalCompiler { get; set; } #

Gets or sets the process-wide expression compiler. Null selects the built-in C# compiler.

Remarks

Set this property before loading schemes. Every assignment, even the same value, invalidates functions that Core compiled earlier. To change the compiler, stop accepting new workflow operations, assign the compiler, and reload schemes and processes before resuming. Follow these steps when changing its internal policy too. Running functions are not interrupted. Core can call the compiler concurrently. This setting is independent of the Code Actions compiler.

public static IExternalExpressionsCompiler DefaultCompiler { get; } #

Gets the built-in C# compiler for explicit delegation from an external compiler.

Remarks

Calling this compiler does not call ExternalCompiler or fall back to a literal. It provides no sandbox or execution limits. When Core stores the returned function, it adds a check that rejects later calls if the compiler registration has changed.

public static bool CompilationEnable { get; set; } #

Gets or sets whether workflow expression compilation is enabled.

Remarks

This static setting applies to built-in and external compilers throughout the application process. When disabled, a request to compile a new expression through ExpressionManager throws InvalidOperationException, and Designer validation fails. Compiled functions can still run if the compiler registration has not changed. This setting does not interrupt running functions and is independent of Code Actions compilation.

public static ExpressionsCompilerOptions Options { get; set; } #

Gets or sets the ExpressionsCompilerOptions used during expression compilation.

Remarks

This static setting applies process-wide.

Methods

public static void RegisterAssembly(Assembly assembly) #

Adds the namespaces used by types in an Assembly to the imports available to subsequently compiled expressions.

Parameters

Name
Type
Description
assembly
Assembly
The assembly whose distinct namespace names are added to the import set.

Exceptions

Type
Description
ReflectionTypeLoadException
Thrown when one or more types from assembly cannot be loaded.

Remarks

Registration applies process-wide. This method adds namespace imports but does not add an assembly metadata reference to the compiler.

public static ExpressionsInvoker CompileExpressions(ProcessDefinition processDefinition) #

Compiles the ConditionType.Expression conditions in a process scheme into one Boolean delegate per transition, keyed by the transition name.

Parameters

Name
Type
Description
processDefinition
ProcessDefinition
The process scheme whose transition expressions are compiled.

Returns

Type
Description
ExpressionsInvoker
An ExpressionsInvoker containing the compiled transition delegates. The invoker is empty when expression compilation is disabled or the scheme contains no expression conditions.

Exceptions

Type
Description
Exception
Thrown when an applicable transition expression cannot be compiled.

Remarks

Multiple expression conditions on the same transition are combined according to TransitionDefinition.ConditionsConcatenationType. The compiler also applies ConditionDefinition.ConditionInversion and ConditionDefinition.ResultOnPreExecution before combining the conditions.

public static SubprocessNameGetterInvoker CompileSubprocessNameGetters(ProcessDefinition processDefinition) #

Compiles a subprocess-name delegate for each transition whose TransitionDefinition.SubprocessName is not blank.

Parameters

Name
Type
Description
processDefinition
ProcessDefinition
The process scheme whose subprocess-name values are compiled.

Returns

Type
Description
SubprocessNameGetterInvoker
A SubprocessNameGetterInvoker containing delegates keyed by transition name. The invoker is empty when expression compilation is disabled or no transition has a nonblank subprocess name.

Remarks

Each configured value is prepared and compiled as an expression that returns a subprocess name. If built-in compilation fails, Core uses the prepared text as a literal name. External compiler errors always reach the caller. Errors while evaluating a compiled expression also reach the caller without literal fallback.

Remarks

Before compilation, recognized workflow operators and process-parameter references are converted to C# expression syntax.