elsa-core/src/samples/console/Elsa.Samples.IfElseConsole/Program.cs

32 lines
1 KiB
C#
Raw Normal View History

2020-10-29 20:36:28 +00:00
using System.Threading.Tasks;
using Elsa.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Samples.IfElseConsole
{
/// <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()
.AddWorkflow<HappinessWorkflow>()
.BuildServiceProvider();
// Run startup actions (not needed when registering Elsa with a Host).
var startupRunner = services.GetRequiredService<IStartupRunner>();
await startupRunner.StartupAsync();
// Get a workflow runner.
var workflowRunner = services.GetService<IWorkflowRunner>();
// Execute the workflow.
await workflowRunner.RunWorkflowAsync<HappinessWorkflow>();
}
}
}