# Class FunctionInvoker OptimaJet.Workflow.Core.CodeActions.FunctionInvoker Stores asynchronous workflow functions by transition name and invokes them for process instances. Namespace: [OptimaJet.Workflow.Core.CodeActions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/) ```csharp public abstract class FunctionInvoker ``` ## Type Hierarchy - FunctionInvoker Current type - [ExpressionsInvoker](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/ExpressionsInvoker/) - [SubprocessNameGetterInvoker](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/SubprocessNameGetterInvoker/) ## Constructors `public FunctionInvoker()` Initializes a new instance of the [FunctionInvoker](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn/) type. ## Properties `protected abstract FunctionInvoker.InvokerNotFoundReactionType InvokerNotFoundReaction { get; }` Gets the behavior applied by the [FunctionInvoker.InvokeAsync(TransitionDefinition, ProcessInstance)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn/) methods when no function is registered for the requested transition. `public abstract string FunctionName { get; }` Gets the label included in compilation-error and missing-function messages. ## Methods `public void RegisterFunctions(IDictionary>> functions)` Registers compiled transition functions by transition name. ### Parameters | Name | Type | Description | | --- | --- | --- | | `functions` | `IDictionary>` | A map from transition names to functions that evaluate a [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Exceptions | Type | Description | | --- | --- | | `ArgumentException` | Thrown when a function is already registered for one of the supplied transition names. | | `ArgumentNullException` | Thrown when one of the supplied transition names is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | `public Task InvokeAsync(TransitionDefinition transitionDefinition, ProcessInstance processInstance)` Invokes the compiled function identified by `transitionDefinition` for the supplied `processInstance`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `transitionDefinition` | `TransitionDefinition` | The [TransitionDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) whose TransitionDefinition.Name is used for lookup. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the selected function. | ### Returns | Type | Description | | --- | --- | | `Task` | The value returned by the selected function, or [default](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/default) for `TReturn` when no function is registered and the derived invoker uses [FunctionInvoker.InvokerNotFoundReactionType.ReturnDefault](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn.InvokerNotFoundReactionType/). | ### Exceptions | Type | Description | | --- | --- | | `Exception` | Thrown when no function is registered for the transition and the derived invoker does not return a default value for missing functions. Exceptions raised by a registered function are propagated. | | `ArgumentNullException` | Thrown when TransitionDefinition.Name is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | `public Task InvokeAsync(string transitionName, ProcessInstance processInstance)` Invokes the compiled function identified by `transitionName` for the supplied `processInstance`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `transitionName` | `String` | The transition name used to locate the compiled function. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) passed to the selected function. | ### Returns | Type | Description | | --- | --- | | `Task` | The value returned by the selected function, or [default](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/default) for `TReturn` when no function is registered and [FunctionInvoker.InvokerNotFoundReaction](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn/) is [FunctionInvoker.InvokerNotFoundReactionType.ReturnDefault](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn.InvokerNotFoundReactionType/). | ### Exceptions | Type | Description | | --- | --- | | `Exception` | Thrown when no function is registered for `transitionName` and [FunctionInvoker.InvokerNotFoundReaction](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn/) is not [FunctionInvoker.InvokerNotFoundReactionType.ReturnDefault](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn.InvokerNotFoundReactionType/). Exceptions raised by a registered function are propagated. | | `ArgumentNullException` | Thrown when `transitionName` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | ### Remarks If the transition is not registered and [FunctionInvoker.InvokerNotFoundReaction](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn/) is [FunctionInvoker.InvokerNotFoundReactionType.ReturnDefault](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn.InvokerNotFoundReactionType/), [default](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/default) is returned. Otherwise [Exception](https://learn.microsoft.com/dotnet/api/system.exception) is thrown. ## Nested Types `protected enum FunctionInvoker.InvokerNotFoundReactionType` Defines the behavior when a requested transition function is missing. [View FunctionInvoker.InvokerNotFoundReactionType](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn.InvokerNotFoundReactionType/) [Previous ExpressionsUtils](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/ExpressionsUtils/) [Next FunctionInvoker.InvokerNotFoundReactionType](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/FunctionInvoker-TReturn.InvokerNotFoundReactionType/)