# Class CodeActionsInvoker OptimaJet.Workflow.Core.CodeActions.CodeActionsInvoker Stores compiled actions, conditions, and rules and invokes them by their logical names. Namespace: [OptimaJet.Workflow.Core.CodeActions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/) ```csharp public sealed class CodeActionsInvoker ``` ## Methods `public void AddCompilledType(Type compilledType)` Discovers generated public static code-action methods on `compilledType` and registers delegates for invoking them. ### Parameters | Name | Type | Description | | --- | --- | --- | | `compilledType` | `Type` | The compiled type that contains code action methods. | ### Exceptions | Type | Description | | --- | --- | | `ArgumentException` | Thrown when a public static method does not end with a recognized [CodeActionType](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/), or when the same generated method name is registered more than once. | ### Remarks The final underscore-delimited segment of each method name, before an optional `Async` suffix, must identify its [CodeActionType](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/). Invocation methods reconstruct the registered method name with [CodeActionUtils.GetMethodName(string, CodeActionType)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/CodeActionUtils/) or [CodeActionUtils.GetAsyncMethodName(string, CodeActionType)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/CodeActionUtils/). `public bool InvokeCondition(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string parameter)` Invokes a synchronous [CodeActionType.Condition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.Condition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name used for lookup. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the invoked code action method. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) passed to the invoked code action method. | | `parameter` | `String` | The parameter string passed to the invoked condition. | ### Returns | Type | Description | | --- | --- | | `Boolean` | The Boolean value returned by the condition. | ### Exceptions | Type | Description | | --- | --- | | `KeyNotFoundException` | Thrown when no synchronous condition is registered for `name`. | `public Task InvokeConditionAsync(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string parameter, CancellationToken token)` Invokes an asynchronous [CodeActionType.Condition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.Condition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name used for lookup. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the invoked code action method. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) passed to the invoked code action method. | | `parameter` | `String` | The parameter string passed to the invoked condition. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) forwarded to the invoked async method. | ### Returns | Type | Description | | --- | --- | | `Task` | A Task whose result is [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the invoked condition evaluates to [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | ### Exceptions | Type | Description | | --- | --- | | `KeyNotFoundException` | Thrown when no asynchronous condition is registered for `name`. | `public void InvokeAction(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string parameter)` Invokes a synchronous [CodeActionType.Action](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.Action](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name used for lookup. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the invoked code action method. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) passed to the invoked code action method. | | `parameter` | `String` | The parameter string passed to the invoked action. | ### Exceptions | Type | Description | | --- | --- | | `KeyNotFoundException` | Thrown when no synchronous action is registered for `name`. | `public Task InvokeActionAsync(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string parameter, CancellationToken token)` Invokes an asynchronous [CodeActionType.Action](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.Action](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name used for lookup. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the invoked code action method. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) passed to the invoked code action method. | | `parameter` | `String` | The parameter string passed to the invoked action. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) forwarded to the invoked async method. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous execution. | ### Exceptions | Type | Description | | --- | --- | | `KeyNotFoundException` | Thrown when no asynchronous action is registered for `name`. | `public IEnumerable InvokeRuleGet(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string parameter)` Invokes a synchronous [CodeActionType.RuleGet](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.RuleGet](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name used for lookup. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the invoked code action method. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) passed to the invoked code action method. | | `parameter` | `String` | The parameter string passed to the invoked rule. | ### Returns | Type | Description | | --- | --- | | `IEnumerable` | The workflow participant identities returned by the rule. | ### Exceptions | Type | Description | | --- | --- | | `KeyNotFoundException` | Thrown when no synchronous identity-producing rule is registered for `name`. | `public Task> InvokeRuleGetAsync(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string parameter, CancellationToken token)` Invokes an asynchronous [CodeActionType.RuleGet](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.RuleGet](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name used for lookup. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the invoked code action method. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) passed to the invoked code action method. | | `parameter` | `String` | The parameter string passed to the invoked rule. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) forwarded to the invoked async method. | ### Returns | Type | Description | | --- | --- | | `Task` | The workflow participant identities returned by the rule. | ### Exceptions | Type | Description | | --- | --- | | `KeyNotFoundException` | Thrown when no asynchronous identity-producing rule is registered for `name`. | `public bool InvokeRuleCheck(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string identityId, string parameter)` Invokes a synchronous [CodeActionType.RuleCheck](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.RuleCheck](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name used for lookup. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the invoked code action method. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) passed to the invoked code action method. | | `identityId` | `String` | The workflow participant identity evaluated by the rule-check action. | | `parameter` | `String` | The parameter string passed to the invoked rule. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the rule accepts the workflow participant identity; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | ### Exceptions | Type | Description | | --- | --- | | `KeyNotFoundException` | Thrown when no synchronous identity-checking rule is registered for `name`. | `public Task InvokeRuleCheckAsync(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string identityId, string parameter, CancellationToken token)` Invokes an asynchronous [CodeActionType.RuleCheck](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.RuleCheck](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name used for lookup. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the invoked code action method. | | `runtime` | `WorkflowRuntime` | The [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) passed to the invoked code action method. | | `identityId` | `String` | The workflow participant identity evaluated by the rule-check action. | | `parameter` | `String` | The parameter string passed to the invoked rule. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) forwarded to the invoked async method. | ### Returns | Type | Description | | --- | --- | | `Task` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the rule accepts the workflow participant identity; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | ### Exceptions | Type | Description | | --- | --- | | `KeyNotFoundException` | Thrown when no asynchronous identity-checking rule is registered for `name`. | `public bool ExistsCondition(string name)` Determines whether a [CodeActionType.Condition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action with the given logical name exists. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.Condition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if a synchronous or asynchronous condition is registered; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `public bool ExistsAction(string name)` Determines whether a [CodeActionType.Action](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action with the given logical name exists. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.Action](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if a synchronous or asynchronous action is registered; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `public bool ExistsRuleGet(string name)` Determines whether a [CodeActionType.RuleGet](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action with the given logical name exists. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.RuleGet](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if a synchronous or asynchronous identity-producing rule is registered; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `public bool ExistsRuleCheck(string name)` Determines whether a [CodeActionType.RuleCheck](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action with the given logical name exists. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.RuleCheck](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if a synchronous or asynchronous identity-checking rule is registered; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `public bool IsConditionAsync(string name)` Determines whether the named [CodeActionType.Condition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action is registered as asynchronous. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.Condition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the condition action is available asynchronously. | `public bool IsActionAsync(string name)` Determines whether the named [CodeActionType.Action](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action is registered as asynchronous. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.Action](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the action is available asynchronously. | `public bool IsGetRuleAsync(string name)` Determines whether the named [CodeActionType.RuleGet](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action is registered as asynchronous. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.RuleGet](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the rule-get action is available asynchronously. | `public bool IsCheckRuleAsync(string name)` Determines whether the named [CodeActionType.RuleCheck](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) code action is registered as asynchronous. ### Parameters | Name | Type | Description | | --- | --- | --- | | `name` | `String` | The logical [CodeActionType.RuleCheck](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CodeActionType/) name. | ### Returns | Type | Description | | --- | --- | | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the rule-check action is available asynchronously. | [Previous CodeActionsCompiller](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/CodeActionsCompiller/) [Next CodeActionUtils](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/CodeActionUtils/)