Class ActivityDefinition
- Namespace
- Temporalio.Activities
- Assembly
- Temporalio.dll
Definition of an activity.
public class ActivityDefinition
- Inheritance
-
ActivityDefinition
- Inherited Members
Properties
Dynamic
Gets a value indicating whether the activity is dynamic.
public bool Dynamic { get; }
Property Value
MethodInfo
Gets the MethodInfo. Will only have a value if one was used to create this ActivityDefinition.
public MethodInfo? MethodInfo { get; }
Property Value
Name
Gets the activity name or null if workflow is dynamic.
public string? Name { get; }
Property Value
ParameterTypes
Gets the parameter types for the definition. This is used by the activity worker to know what to deserialize input values into.
public IReadOnlyCollection<Type> ParameterTypes { get; }
Property Value
RequiredParameterCount
Gets the number of parameters required to be sent to InvokeAsync(object?[]). Activity invocation will fail if fewer are given.
public int RequiredParameterCount { get; }
Property Value
ReturnType
Gets the return type for the definition. This may be a Task for async activities. This is currently unused (callers are expected to provide the return type as needed).
public Type ReturnType { get; }
Property Value
Methods
Create(Delegate)
Create an activity definition from a delegate. DynamicInvoke(params object[]) is called on this delegate. The delegate must have an associated method and that method must have ActivityAttribute set on it.
public static ActivityDefinition Create(Delegate del)
Parameters
delDelegateDelegate to create definition from.
Returns
- ActivityDefinition
Definition built from the delegate.
Create(MethodInfo, Func<object?[], object?>)
Create an activity definition with an attributed method and a custom invoker.
public static ActivityDefinition Create(MethodInfo method, Func<object?[], object?> invoker)
Parameters
methodMethodInfoActivity method.
invokerFunc<object[], object>Invoker.
Returns
- ActivityDefinition
Definition for the activity.
Create(string?, Type, IReadOnlyCollection<Type>, int, Func<object?[], object?>)
Create an activity definition manually from the given values.
public static ActivityDefinition Create(string? name, Type returnType, IReadOnlyCollection<Type> parameterTypes, int requiredParameterCount, Func<object?[], object?> invoker)
Parameters
namestringName to use for the activity or null for dynamic.
returnTypeTypeReturn type of the activity. This is currently unused.
parameterTypesIReadOnlyCollection<Type>Parameter types for the invoker.
requiredParameterCountintMinimum number of parameters that must be provided to the invoker.
invokerFunc<object[], object>Function to call on activity invocation.
Returns
- ActivityDefinition
Definition built from the given pieces.
CreateAll(Type, object?)
Create all applicable activity definitions for the given type. At least one activity definition must exist.
public static IReadOnlyCollection<ActivityDefinition> CreateAll(Type type, object? instance)
Parameters
typeTypeType with activity definitions.
instanceobjectInstance to invoke the activity definitions on. Must be non-null if any activities are non-static.
Returns
- IReadOnlyCollection<ActivityDefinition>
Collection of activity definitions on the type.
CreateAll<T>(T?)
Create all applicable activity definitions for the given type. At least one activity definition must exist.
public static IReadOnlyCollection<ActivityDefinition> CreateAll<T>(T? instance)
Parameters
instanceTInstance to invoke the activity definitions on. Must be non-null if any activities are non-static.
Returns
- IReadOnlyCollection<ActivityDefinition>
Collection of activity definitions on the type.
Type Parameters
TType with activity definitions.
CreateWithoutAttribute(string?, MethodInfo, Func<object?[], object?>)
Create an activity definition with a name, a method, and a custom invoker. This does not require/check the activity attribute. This is a helper for Create(string, Type, IReadOnlyCollection<Type>, int, Func<object[], object>, MethodInfo) that collects parameters and handles parameter defaults.
public static ActivityDefinition CreateWithoutAttribute(string? name, MethodInfo method, Func<object?[], object?> invoker)
Parameters
namestringName to use for the activity or null for dynamic.
methodMethodInfoActivity method.
invokerFunc<object[], object>Invoker.
Returns
- ActivityDefinition
Definition for the activity.
InvokeAsync(object?[])
Invoke this activity with the given parameters. Before calling this, callers should have already validated that the parameters match ParameterTypes and there are at least RequiredParameterCount parameters. If the activity returns a Task, it is waited on and the result is extracted. If it is an untyped Task, the successful result will be Task<ValueTuple>.
public Task<object?> InvokeAsync(object?[] parameters)
Parameters
parametersobject[]Parameters for the call.