Extending Pipelines
Modify system behavior by modifying Pipelines.
Ucommerce Pipelines are the primary extension points where you can execute any custom logic to fit your requirements. These extensions could be changing the existing behavior of the pipelines, adding new steps to be executed, and integrating with other systems.
Implementing a Task
Before implementing a new Pipeline Task, we must identify which pipeline we want to extend, specifically the input and output parameter types. In the examples below, we'll use XPipelineInput and XPipelineOutput to signify the types, as they follow the naming convention of the Pipeline name followed by Input or Output.
Create a new Class.
Inherit from
IPipelineTask<XPipelineInput, XPipelineOutput>Implement the Execute method.
public class MyCustomTask : IPipelineTask<XPipelineInput, XPipelineOutput>
{
public CascadeMode CascadeMode { get; } = CascadeMode.Continue;
public Task Execute(PipelineContext<XPipelineInput, XPipelineOutput> context, CancellationToken cancellationToken)
{
// Your custom logic.
}
}Adding a Task
The next step is registering the PipelineTask in the IoC container for the proper Pipeline and position. This can be done via the Ucommerce builder, and it is recommended to use a helper method for reusability and clarity.
Extension method example
This example displays different ways of modifying a pipeline.
Register your custom pipeline tasks, using an extension method
Now you can register all of your customized pipeline tasks using your extension method like this.
Last updated
Was this helpful?