A reference to Elsa.EntityFrameworkCore.Sqlite.csproj was added in the Elsa.Samples.AspNet.DynamicActivityProvider.csproj, providing SQLite support. The Add method in ExpressionDescriptorRegistry.cs was reformatted for better readability. In the Program.cs file, the signing key was updated to meet the minimum length requirement and some unnecessary comments were removed. |
||
|---|---|---|
| .. | ||
| ActivityProviders | ||
| Data | ||
| Models | ||
| Properties | ||
| Workflows | ||
| appsettings.Development.json | ||
| appsettings.json | ||
| Elsa.Samples.AspNet.DynamicActivityProvider.csproj | ||
| Program.cs | ||
| Readme.md | ||
| sample-requests.http | ||
Dynamic Activity Providers
This sample project demonstrates how to implement a dynamic activity provider.
Overview
The key to providing activities dynamically to the activity registry is to implement the IActivityProvider interface. This interface defines a single method, GetDescriptorsAsync, which returns a list of activity descriptors.
In this example, we are loading API endpoint definitions from a JSON file located in the Data folder and create an activity descriptor for each endpoint.
The activity descriptor is then used to create an activity type, which is then registered with the activity registry.
This example could be applied to any other data source, such as a database or a web service, Open API specifications, GraphQL, etc.
Usage
- Run the sample project.
- Open the workflow editor.
- Notice the new activities in the toolbox.
- Drag one of the new activities onto the canvas.
- Notice the new activity in the canvas.
- Run the workflow.
- Notice the new activity being executed.
Notes
This project provides sample workflows that you can import into the workflow editor. The workflows are located in the Workflows folder.
You can then use the workflow editor to inspect the workflows and see how the activities are used.
When imported, you can invoke the workflows using the sample-request.http file located in the root folder containing this project.