Table of Contents

Interface IWorkflowExecutionContext

Namespace
WorkflowForge.Abstractions
Assembly
WorkflowForge.dll

Provides access to the execution context for workflow operations. This interface represents the ambient context pattern, giving operations access to runtime state, properties, logging, and dependency injection services.

public interface IWorkflowExecutionContext

Remarks

This interface follows the Interface Segregation Principle (ISP), providing only context-related members. Operations that only need to read context data can depend on this interface rather than the full IWorkflowFoundry.

Properties

CurrentWorkflow

Gets the workflow currently being executed in this foundry. Can be null if no workflow is currently executing. This reference is updated when workflows are executed through the foundry. Access workflow.Id and workflow.Name through this property.

IWorkflow? CurrentWorkflow { get; }

Property Value

IWorkflow

ExecutionId

Gets the unique identifier for the current foundry execution instance. This identifier is unique per foundry instance and persists across workflow executions.

Guid ExecutionId { get; }

Property Value

Guid

Logger

Gets the logger for this foundry context. All logging within the foundry should use this logger for consistent output and correlation.

IWorkflowForgeLogger Logger { get; }

Property Value

IWorkflowForgeLogger

Options

Gets the execution options for this foundry.

WorkflowForgeOptions Options { get; }

Property Value

WorkflowForgeOptions

Properties

Gets the properties dictionary for the foundry. Thread-safe dictionary for storing and retrieving properties during workflow execution.

Isolation: A foundry lease never shares property data with a concurrent lease. Concurrent workflow executions therefore cannot collide on property data.

Lifecycle: On the default pooled smith path, Properties are cleared after each workflow. When you pass a caller-owned foundry to ForgeAsync(workflow, foundry), properties persist until you dispose that foundry. When you pass a dictionary to ForgeAsync(workflow, data), the smith uses it directly and leaves its contents in place so results can be read back. Values in Properties are never auto-disposed; use Services for extension-owned IDisposable resources.

Use extension methods (GetProperty, SetProperty, TryGetProperty) for convenient access patterns.

ConcurrentDictionary<string, object?> Properties { get; }

Property Value

ConcurrentDictionary<string, object>

ServiceProvider

Gets the service provider for dependency injection. Can be null if no dependency injection is configured for this foundry.

IServiceProvider? ServiceProvider { get; }

Property Value

IServiceProvider

Services

Gets foundry-scoped services (extension capabilities). Disposed when the foundry lease ends.

IFoundryServices Services { get; }

Property Value

IFoundryServices

Methods

SetCurrentWorkflow(IWorkflow?)

Sets the current workflow being executed in this foundry. This method is typically called internally by the workflow smith during execution.

void SetCurrentWorkflow(IWorkflow? workflow)

Parameters

workflow IWorkflow

The workflow to set as current. Can be null to clear the current workflow.

Exceptions

ObjectDisposedException

Thrown when the foundry has been disposed.