2022-11-10 13:40:37 +00:00
|
|
|
|
using Elsa.Extensions;
|
|
|
|
|
|
using Elsa.Workflows.Core.Activities;
|
2023-03-03 21:47:23 +00:00
|
|
|
|
using Elsa.Workflows.Core.Contracts;
|
2022-11-10 13:40:37 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
|
|
// Setup service container.
|
|
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
|
|
|
|
|
|
|
// Add Elsa services.
|
|
|
|
|
|
services.AddElsa();
|
|
|
|
|
|
|
|
|
|
|
|
// Build service container.
|
|
|
|
|
|
var serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
|
|
2022-12-30 12:11:29 +00:00
|
|
|
|
// Define a simple workflow, which in this case is a very simple activity that writes something to the console:
|
|
|
|
|
|
var workflow = new WriteLine("Hello world!");
|
2022-11-10 13:40:37 +00:00
|
|
|
|
|
|
|
|
|
|
// Resolve a workflow runner to run the workflow.
|
|
|
|
|
|
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();
|
|
|
|
|
|
|
|
|
|
|
|
// Run the workflow.
|
|
|
|
|
|
await workflowRunner.RunAsync(workflow);
|