Table of Contents

Interface IWorkflowOperation

Namespace
WorkflowForge.Abstractions
Assembly
WorkflowForge.dll

Represents a single operation within a workflow that can be forged (executed) in the foundry. Operations are the building blocks of workflows, each performing a specific task. In the Workflow Forge metaphor, operations are the tools and processes used to shape raw materials into finished products.

public interface IWorkflowOperation : IDisposable
Inherited Members
Extension Methods

Remarks

For most scenarios, inherit from WorkflowOperationBase instead of implementing this interface directly. The base class provides:

  • Automatic unique ID generation
  • Default no-op RestoreAsync and Dispose implementations
  • Lifecycle hooks (OnBeforeExecuteAsync, OnAfterExecuteAsync)
  • Separation of orchestration (ForgeAsync) from business logic (ForgeAsyncCore)
Direct implementation of this interface is an advanced scenario for cases where you need full control over the operation lifecycle or cannot inherit from a base class.

Properties

Id

Gets the unique identifier for this operation.

Guid Id { get; }

Property Value

Guid

Name

Gets the name of this operation for identification and logging purposes.

string Name { get; }

Property Value

string

Methods

ForgeAsync(object?, IWorkflowFoundry, CancellationToken)

Forges (executes) the operation's primary logic with explicit input data and returns output data. The orchestrator controls what data flows into and out of each operation.

Task<object?> ForgeAsync(object? inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)

Parameters

inputData object

The input data for this operation (can be null).

foundry IWorkflowFoundry

The workflow foundry providing execution context and shared services.

cancellationToken CancellationToken

The cancellation token for cooperative cancellation.

Returns

Task<object>

A task representing the asynchronous operation with optional output data.

Exceptions

ArgumentNullException

Thrown when foundry is null.

ObjectDisposedException

Thrown when the operation has been disposed.

RestoreAsync(object?, IWorkflowFoundry, CancellationToken)

Restores (compensates) the operation's effects to undo its changes. Used for rollback scenarios when subsequent operations fail.

Task RestoreAsync(object? outputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)

Parameters

outputData object

The data that was produced by this operation during ForgeAsync.

foundry IWorkflowFoundry

The workflow foundry providing execution context and shared services.

cancellationToken CancellationToken

The cancellation token for cooperative cancellation.

Returns

Task

A task representing the asynchronous restoration.

Exceptions

ArgumentNullException

Thrown when foundry is null.

ObjectDisposedException

Thrown when the operation has been disposed.