Table of Contents

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

bool

MethodInfo

Gets the MethodInfo. Will only have a value if one was used to create this ActivityDefinition.

public MethodInfo? MethodInfo { get; }

Property Value

MethodInfo

Name

Gets the activity name or null if workflow is dynamic.

public string? Name { get; }

Property Value

string

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

IReadOnlyCollection<Type>

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

int

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

Type

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

del Delegate

Delegate 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

method MethodInfo

Activity method.

invoker Func<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

name string

Name to use for the activity or null for dynamic.

returnType Type

Return type of the activity. This is currently unused.

parameterTypes IReadOnlyCollection<Type>

Parameter types for the invoker.

requiredParameterCount int

Minimum number of parameters that must be provided to the invoker.

invoker Func<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

type Type

Type with activity definitions.

instance object

Instance 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

instance T

Instance 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

T

Type with activity definitions.

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

parameters object[]

Parameters for the call.

Returns

Task<object>

Task for result.