Class WorkflowOperationBase<TInput, TOutput>
- Namespace
- WorkflowForge.Operations
- Assembly
- WorkflowForge.dll
Base class for typed workflow operations providing automatic type conversion for the untyped interface. Includes lifecycle hooks for before/after execution without requiring middleware.
public abstract class WorkflowOperationBase<TInput, TOutput> : WorkflowOperationBase, IWorkflowOperation<TInput, TOutput>, IWorkflowOperation, IDisposable
Type Parameters
TInputThe type of input data this operation expects.
TOutputThe type of output data this operation produces.
- Inheritance
-
WorkflowOperationBase<TInput, TOutput>
- Implements
-
IWorkflowOperation<TInput, TOutput>
- Derived
- Inherited Members
- Extension Methods
Methods
ForgeAsync(TInput, IWorkflowFoundry, CancellationToken)
Executes the typed operation with lifecycle hooks.
public Task<TOutput> ForgeAsync(TInput inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
inputDataTInputThe typed input data.
foundryIWorkflowFoundryThe workflow foundry providing context and services.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<TOutput>
The typed output data.
ForgeAsyncCore(object?, IWorkflowFoundry, CancellationToken)
Implements the untyped interface by casting to/from the typed interface. DO NOT OVERRIDE THIS METHOD - it handles type conversion automatically.
protected override sealed Task<object?> ForgeAsyncCore(object? inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
inputDataobjectfoundryIWorkflowFoundrycancellationTokenCancellationToken
Returns
ForgeAsyncCore(TInput, IWorkflowFoundry, CancellationToken)
Strongly-typed core operation logic. This is the main method you should override in your custom operations.
protected abstract Task<TOutput> ForgeAsyncCore(TInput inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
inputDataTInputThe typed input data.
foundryIWorkflowFoundryThe workflow foundry providing context and services.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<TOutput>
The typed output data.
OnAfterExecuteAsync(object?, object?, IWorkflowFoundry, CancellationToken)
Overrides base hooks to prevent double-calling when typed hooks are used.
protected override Task OnAfterExecuteAsync(object? inputData, object? outputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
inputDataobjectoutputDataobjectfoundryIWorkflowFoundrycancellationTokenCancellationToken
Returns
OnAfterExecuteAsync(TInput, TOutput, IWorkflowFoundry, CancellationToken)
Called after the operation executes successfully with typed data. Override to add cleanup/finalization logic.
protected virtual Task OnAfterExecuteAsync(TInput inputData, TOutput outputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
inputDataTInputThe typed input data that was passed to the operation.
outputDataTOutputThe typed 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)
Overrides base hooks to prevent double-calling when typed hooks are used.
protected override Task OnBeforeExecuteAsync(object? inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
inputDataobjectfoundryIWorkflowFoundrycancellationTokenCancellationToken
Returns
OnBeforeExecuteAsync(TInput, IWorkflowFoundry, CancellationToken)
Called before the operation executes with typed input. Override to add setup/initialization logic.
protected virtual Task OnBeforeExecuteAsync(TInput inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
inputDataTInputThe typed 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)
Implements the untyped restoration interface. DO NOT OVERRIDE THIS METHOD - it handles type conversion automatically.
public override sealed Task RestoreAsync(object? outputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
outputDataobjectfoundryIWorkflowFoundrycancellationTokenCancellationToken
Returns
RestoreAsync(TOutput, IWorkflowFoundry, CancellationToken)
Strongly-typed restoration logic. Override this method if your operation supports restoration/rollback.
public virtual Task RestoreAsync(TOutput outputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
outputDataTOutputThe typed output data to restore.
foundryIWorkflowFoundryThe workflow foundry providing context and services.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the restoration operation.