elsa-core/src/samples/console/Elsa.Samples.IfElseConsole/Program.cs
2020-12-12 14:07:17 +01:00

34 lines
1.1 KiB
C#

using System.Threading.Tasks;
using Elsa.Persistence.InMemory;
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.GetRequiredService<IWorkflowRunner>();
// Execute the workflow.
await workflowRunner.RunWorkflowAsync<HappinessWorkflow>();
}
}
}