Table of Contents

Class FoundryPropertyExtensions

Namespace
WorkflowForge.Extensions
Assembly
WorkflowForge.dll

Extension methods for IWorkflowFoundry providing property access, operation chaining, and fluent API helpers. This file focuses on property management and operation building. For middleware configuration, see FoundryMiddlewareExtensions.

public static class FoundryPropertyExtensions
Inheritance
FoundryPropertyExtensions
Inherited Members

Methods

GetCorrelationId(IWorkflowFoundry)

Gets correlation ID from foundry data.

public static string? GetCorrelationId(this IWorkflowFoundry foundry)

Parameters

foundry IWorkflowFoundry

Returns

string

GetOperationOutput(IWorkflowFoundry, int, string)

Gets the output of a specific operation by its position in the workflow. This is an orchestrator-level API for workflow composition and test inspection. Operations should NOT use this to read other operations' outputs -- use the input parameter of ForgeAsyncCore or foundry.Properties with domain-specific keys instead.

public static object? GetOperationOutput(this IWorkflowFoundry foundry, int operationIndex, string operationName)

Parameters

foundry IWorkflowFoundry

The foundry to read from.

operationIndex int

The zero-based index of the operation in the workflow.

operationName string

The name of the operation at that index.

Returns

object

The operation output, or null if not found.

Exceptions

ArgumentNullException

Thrown when foundry is null.

ArgumentOutOfRangeException

Thrown when operationIndex is negative.

ArgumentException

Thrown when operationName is null or empty.

GetOperationOutput<T>(IWorkflowFoundry, int, string)

Gets the strongly-typed output of a specific operation by its position in the workflow. This is an orchestrator-level API for workflow composition and test inspection. Operations should NOT use this to read other operations' outputs -- use the input parameter of ForgeAsyncCore or foundry.Properties with domain-specific keys instead.

public static T? GetOperationOutput<T>(this IWorkflowFoundry foundry, int operationIndex, string operationName)

Parameters

foundry IWorkflowFoundry

The foundry to read from.

operationIndex int

The zero-based index of the operation in the workflow.

operationName string

The name of the operation at that index.

Returns

T

The operation output cast to T, or default if not found or wrong type.

Type Parameters

T

The expected output type.

Exceptions

ArgumentNullException

Thrown when foundry is null.

ArgumentOutOfRangeException

Thrown when operationIndex is negative.

ArgumentException

Thrown when operationName is null or empty.

GetPropertyOrDefault<T>(IWorkflowFoundry, string)

Gets a strongly-typed value from the foundry properties, or default if not present or of wrong type.

public static T? GetPropertyOrDefault<T>(this IWorkflowFoundry foundry, string key)

Parameters

foundry IWorkflowFoundry
key string

Returns

T

Type Parameters

T

GetPropertyOrDefault<T>(IWorkflowFoundry, string, T)

Gets a strongly-typed value from the foundry properties, or the provided default when missing.

public static T GetPropertyOrDefault<T>(this IWorkflowFoundry foundry, string key, T defaultValue)

Parameters

foundry IWorkflowFoundry
key string
defaultValue T

Returns

T

Type Parameters

T

SetCorrelationId(IWorkflowFoundry, string)

Sets correlation ID in foundry data for tracking across operations.

public static void SetCorrelationId(this IWorkflowFoundry foundry, string correlationId)

Parameters

foundry IWorkflowFoundry
correlationId string

SetParentWorkflowExecutionId(IWorkflowFoundry, string)

Sets parent workflow execution ID for nested workflow tracking.

public static void SetParentWorkflowExecutionId(this IWorkflowFoundry foundry, string parentWorkflowExecutionId)

Parameters

foundry IWorkflowFoundry
parentWorkflowExecutionId string

SetProperty(IWorkflowFoundry, string, object?)

Sets a value in the foundry properties.

public static IWorkflowFoundry SetProperty(this IWorkflowFoundry foundry, string key, object? value)

Parameters

foundry IWorkflowFoundry
key string
value object

Returns

IWorkflowFoundry

TryGetProperty<T>(IWorkflowFoundry, string, out T?)

Tries to get a strongly-typed value from the foundry properties.

public static bool TryGetProperty<T>(this IWorkflowFoundry foundry, string key, out T? value)

Parameters

foundry IWorkflowFoundry
key string
value T

Returns

bool

Type Parameters

T

WithMiddleware(IWorkflowFoundry, IWorkflowOperationMiddleware)

Adds middleware to the foundry and returns the foundry for method chaining.

public static IWorkflowFoundry WithMiddleware(this IWorkflowFoundry foundry, IWorkflowOperationMiddleware middleware)

Parameters

foundry IWorkflowFoundry

The foundry to add middleware to.

middleware IWorkflowOperationMiddleware

The middleware to add.

Returns

IWorkflowFoundry

The same foundry instance for method chaining.

Exceptions

ArgumentNullException

Thrown when foundry or middleware is null.

WithOperation(IWorkflowFoundry, string, Action<IWorkflowFoundry>, Action<IWorkflowFoundry>?)

Adds an inline synchronous operation to the foundry using a lambda expression.

public static IWorkflowFoundry WithOperation(this IWorkflowFoundry foundry, string name, Action<IWorkflowFoundry> action, Action<IWorkflowFoundry>? restoreAction = null)

Parameters

foundry IWorkflowFoundry

The foundry to add the operation to.

name string

The name of the operation.

action Action<IWorkflowFoundry>

The synchronous action to execute. Takes the foundry as parameter.

restoreAction Action<IWorkflowFoundry>

Optional synchronous restoration action for compensation.

Returns

IWorkflowFoundry

The same foundry instance for method chaining.

Exceptions

ArgumentNullException

Thrown when foundry, name, or action is null.

ArgumentException

Thrown when name is empty or whitespace.

WithOperation(IWorkflowFoundry, string, Func<IWorkflowFoundry, Task>, Func<IWorkflowFoundry, Task>?)

Adds an inline operation to the foundry using a lambda expression.

public static IWorkflowFoundry WithOperation(this IWorkflowFoundry foundry, string name, Func<IWorkflowFoundry, Task> action, Func<IWorkflowFoundry, Task>? restoreAction = null)

Parameters

foundry IWorkflowFoundry

The foundry to add the operation to.

name string

The name of the operation.

action Func<IWorkflowFoundry, Task>

The action to execute. Takes the foundry as parameter.

restoreAction Func<IWorkflowFoundry, Task>

Optional asynchronous restoration action for compensation.

Returns

IWorkflowFoundry

The same foundry instance for method chaining.

Exceptions

ArgumentNullException

Thrown when foundry, name, or action is null.

ArgumentException

Thrown when name is empty or whitespace.

WithOperation(IWorkflowFoundry, IWorkflowOperation)

Adds a single operation to the foundry and returns the foundry for method chaining.

public static IWorkflowFoundry WithOperation(this IWorkflowFoundry foundry, IWorkflowOperation operation)

Parameters

foundry IWorkflowFoundry

The foundry to add the operation to.

operation IWorkflowOperation

The operation to add.

Returns

IWorkflowFoundry

The same foundry instance for method chaining.

Exceptions

ArgumentNullException

Thrown when foundry or operation is null.

WithOperations(IWorkflowFoundry, IEnumerable<IWorkflowOperation>)

Adds operations to the foundry and returns the foundry for method chaining.

public static IWorkflowFoundry WithOperations(this IWorkflowFoundry foundry, IEnumerable<IWorkflowOperation> operations)

Parameters

foundry IWorkflowFoundry

The foundry to add operations to.

operations IEnumerable<IWorkflowOperation>

The operations to add.

Returns

IWorkflowFoundry

The same foundry instance for method chaining.

Exceptions

ArgumentNullException

Thrown when foundry or operations is null.

WithOperations(IWorkflowFoundry, params IWorkflowOperation[])

Adds operations to the foundry and returns the foundry for method chaining.

public static IWorkflowFoundry WithOperations(this IWorkflowFoundry foundry, params IWorkflowOperation[] operations)

Parameters

foundry IWorkflowFoundry

The foundry to add operations to.

operations IWorkflowOperation[]

The operations to add.

Returns

IWorkflowFoundry

The same foundry instance for method chaining.

Exceptions

ArgumentNullException

Thrown when foundry or operations is null.