Assembly: OptimaJet.Workflow.Core

Class FunctionInvoker<TReturn>

OptimaJet.Workflow.Core.CodeActions.FunctionInvoker<TReturn>

Stores asynchronous workflow functions by transition name and invokes them for process instances.

public abstract class FunctionInvoker<TReturn>

Type Hierarchy

Constructors

public FunctionInvoker() #
Initializes a new instance of the FunctionInvoker<TReturn> type.

Properties

protected abstract FunctionInvoker<TReturn>.InvokerNotFoundReactionType InvokerNotFoundReaction { get; } #
Gets the behavior applied by the FunctionInvoker<TReturn>.InvokeAsync(TransitionDefinition, ProcessInstance) 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<string, Func<ProcessInstance, Task<TReturn>>> functions) #
Registers compiled transition functions by transition name.

Parameters

Name
Type
Description
functions
IDictionary<String, ProcessInstance, Task<TReturn>>
A map from transition names to functions that evaluate a 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.
public Task<TReturn> InvokeAsync(TransitionDefinition transitionDefinition, ProcessInstance processInstance) #
Invokes the compiled function identified by transitionDefinition for the supplied processInstance.

Parameters

Name
Type
Description
transitionDefinition
TransitionDefinition
The TransitionDefinition whose TransitionDefinition.Name is used for lookup.
processInstance
ProcessInstance
The ProcessInstance passed to the selected function.

Returns

Type
Description
Task<TReturn>
The value returned by the selected function, or default for TReturn when no function is registered and the derived invoker uses FunctionInvoker<TReturn>.InvokerNotFoundReactionType.ReturnDefault.

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.
public Task<TReturn> 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 passed to the selected function.

Returns

Type
Description
Task<TReturn>
The value returned by the selected function, or default for TReturn when no function is registered and FunctionInvoker<TReturn>.InvokerNotFoundReaction is FunctionInvoker<TReturn>.InvokerNotFoundReactionType.ReturnDefault.

Exceptions

Type
Description
Exception
Thrown when no function is registered for transitionName and FunctionInvoker<TReturn>.InvokerNotFoundReaction is not FunctionInvoker<TReturn>.InvokerNotFoundReactionType.ReturnDefault. Exceptions raised by a registered function are propagated.
ArgumentNullException
Thrown when transitionName is null.

Remarks

Nested Types

protected enum FunctionInvoker<TReturn>.InvokerNotFoundReactionType #
Defines the behavior when a requested transition function is missing.
View FunctionInvoker<TReturn>.InvokerNotFoundReactionType