Extensibility

Elsa Workflows supports custom alteration types, allowing developers to define their own types and utilize them as alterations.

To define a custom alteration type, implement the IAlteration interface.

public interface IAlteration
{
}

Next, implement an alteration handler that handles the alteration type.

public interface IAlterationHandler
{
    bool CanHandle(IAlteration alteration);
    ValueTask HandleAsync(AlterationContext context);
}

Or, derive from the AlterationHandlerBase<T> base class to simplify the implementation.

Finally, register the alteration handler with the service collection.

services.AddElsa(elsa => 
{
    elsa.UseAlterations(alterations => 
    {
        alterations.AddAlteration<MyAlteration, MyAlterationHandler>();
    })
});

Example

The following example demonstrates how to define a custom alteration type and handler.

Last updated