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
foundryIWorkflowFoundry
Returns
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
foundryIWorkflowFoundryThe foundry to read from.
operationIndexintThe zero-based index of the operation in the workflow.
operationNamestringThe 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
foundryIWorkflowFoundryThe foundry to read from.
operationIndexintThe zero-based index of the operation in the workflow.
operationNamestringThe 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
TThe 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
foundryIWorkflowFoundrykeystring
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
foundryIWorkflowFoundrykeystringdefaultValueT
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
foundryIWorkflowFoundrycorrelationIdstring
SetParentWorkflowExecutionId(IWorkflowFoundry, string)
Sets parent workflow execution ID for nested workflow tracking.
public static void SetParentWorkflowExecutionId(this IWorkflowFoundry foundry, string parentWorkflowExecutionId)
Parameters
foundryIWorkflowFoundryparentWorkflowExecutionIdstring
SetProperty(IWorkflowFoundry, string, object?)
Sets a value in the foundry properties.
public static IWorkflowFoundry SetProperty(this IWorkflowFoundry foundry, string key, object? value)
Parameters
foundryIWorkflowFoundrykeystringvalueobject
Returns
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
foundryIWorkflowFoundrykeystringvalueT
Returns
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
foundryIWorkflowFoundryThe foundry to add middleware to.
middlewareIWorkflowOperationMiddlewareThe 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
foundryIWorkflowFoundryThe foundry to add the operation to.
namestringThe name of the operation.
actionAction<IWorkflowFoundry>The synchronous action to execute. Takes the foundry as parameter.
restoreActionAction<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
foundryIWorkflowFoundryThe foundry to add the operation to.
namestringThe name of the operation.
actionFunc<IWorkflowFoundry, Task>The action to execute. Takes the foundry as parameter.
restoreActionFunc<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
foundryIWorkflowFoundryThe foundry to add the operation to.
operationIWorkflowOperationThe 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
foundryIWorkflowFoundryThe foundry to add operations to.
operationsIEnumerable<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
foundryIWorkflowFoundryThe foundry to add operations to.
operationsIWorkflowOperation[]The operations to add.
Returns
- IWorkflowFoundry
The same foundry instance for method chaining.
Exceptions
- ArgumentNullException
Thrown when foundry or operations is null.