Table of Contents

Class WorkflowOperationBase

Namespace
WorkflowForge.Operations
Assembly
WorkflowForge.dll

Base class for untyped workflow operations providing default behaviors (ID, restore guard, disposal). Includes lifecycle hooks for before/after execution without requiring middleware.

public abstract class WorkflowOperationBase : IWorkflowOperation, IDisposable
Inheritance
WorkflowOperationBase
Implements
Derived
Inherited Members
Extension Methods

Properties

Id

Gets the unique identifier for this operation.

public virtual Guid Id { get; }

Property Value

Guid

Name

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

public abstract string Name { get; }

Property Value

string

Methods

Dispose()

public void Dispose()

Dispose(bool)

Releases managed resources. Override in derived classes to dispose of owned resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

True if called from Dispose(), false if from a finalizer.

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.

public 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.

Remarks

This method orchestrates the lifecycle hooks and core execution:

  1. Calls OnBeforeExecuteAsync
  2. Calls ForgeAsyncCore (your operation logic)
  3. Calls OnAfterExecuteAsync

Exceptions

ArgumentNullException

Thrown when foundry is null.

ObjectDisposedException

Thrown when the operation has been disposed.

ForgeAsyncCore(object?, IWorkflowFoundry, CancellationToken)

Core operation logic. Implement this method with your operation's business logic. This is called between OnBeforeExecuteAsync and OnAfterExecuteAsync.

protected abstract Task<object?> ForgeAsyncCore(object? inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)

Parameters

inputData object

The input data for the operation.

foundry IWorkflowFoundry

The workflow foundry providing context and services.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<object>

The output data from the operation.

OnAfterExecuteAsync(object?, object?, IWorkflowFoundry, CancellationToken)

Called after the operation executes successfully. Override to add cleanup/finalization logic.

protected virtual Task OnAfterExecuteAsync(object? inputData, object? outputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)

Parameters

inputData object

The input data that was passed to the operation.

outputData object

The output data produced by the operation.

foundry IWorkflowFoundry

The workflow foundry providing context and services.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task representing the asynchronous operation.

OnBeforeExecuteAsync(object?, IWorkflowFoundry, CancellationToken)

Called before the operation executes. Override to add setup/initialization logic.

protected virtual Task OnBeforeExecuteAsync(object? inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)

Parameters

inputData object

The input data for the operation.

foundry IWorkflowFoundry

The workflow foundry providing context and services.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task representing the asynchronous operation.

RestoreAsync(object?, IWorkflowFoundry, CancellationToken)

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

public virtual 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.

Remarks

The base implementation is a no-op. Override this method in your operation to provide compensation/rollback logic. Operations that don't override this are safely skipped during compensation.

Exceptions

ArgumentNullException

Thrown when foundry is null.

ObjectDisposedException

Thrown when the operation has been disposed.