2020-12-11 20:03:49 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using Elsa.Persistence.InMemory;
|
2020-11-03 11:14:25 +00:00
|
|
|
using Elsa.Samples.GoBackConsole.Activities;
|
|
|
|
|
using Elsa.Samples.GoBackConsole.Workflows;
|
|
|
|
|
using Elsa.Services;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace Elsa.Samples.GoBackConsole
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Demonstrates a workflow with a While looping construct.
|
|
|
|
|
/// </summary>
|
|
|
|
|
static class Program
|
|
|
|
|
{
|
|
|
|
|
private static async Task Main()
|
|
|
|
|
{
|
|
|
|
|
// Create a service container with Elsa services.
|
|
|
|
|
var services = new ServiceCollection()
|
|
|
|
|
.AddElsa()
|
|
|
|
|
.AddConsoleActivities()
|
|
|
|
|
.AddActivity<BrickWallActivity>()
|
|
|
|
|
.AddWorkflow<WalkAroundWorkflow>()
|
|
|
|
|
.BuildServiceProvider();
|
|
|
|
|
|
|
|
|
|
// Run startup actions (not needed when registering Elsa with a Host).
|
|
|
|
|
var startupRunner = services.GetRequiredService<IStartupRunner>();
|
|
|
|
|
await startupRunner.StartupAsync();
|
|
|
|
|
|
|
|
|
|
// Get a workflow runner.
|
2020-12-11 20:35:22 +00:00
|
|
|
var workflowRunner = services.GetRequiredService<IWorkflowRunner>();
|
2020-11-03 11:14:25 +00:00
|
|
|
|
|
|
|
|
// Execute the workflow.
|
|
|
|
|
await workflowRunner.RunWorkflowAsync<WalkAroundWorkflow>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|