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
Name
Gets the name of this operation for identification and logging purposes.
public abstract string Name { get; }
Property Value
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
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
inputDataobjectThe input data for this operation (can be null).
foundryIWorkflowFoundryThe workflow foundry providing execution context and shared services.
cancellationTokenCancellationTokenThe cancellation token for cooperative cancellation.
Returns
Remarks
This method orchestrates the lifecycle hooks and core execution:
- Calls OnBeforeExecuteAsync
- Calls ForgeAsyncCore (your operation logic)
- 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
inputDataobjectThe input data for the operation.
foundryIWorkflowFoundryThe workflow foundry providing context and services.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
inputDataobjectThe input data that was passed to the operation.
outputDataobjectThe output data produced by the operation.
foundryIWorkflowFoundryThe workflow foundry providing context and services.
cancellationTokenCancellationTokenThe 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
inputDataobjectThe input data for the operation.
foundryIWorkflowFoundryThe workflow foundry providing context and services.
cancellationTokenCancellationTokenThe 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
outputDataobjectThe data that was produced by this operation during ForgeAsync.
foundryIWorkflowFoundryThe workflow foundry providing execution context and shared services.
cancellationTokenCancellationTokenThe 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.