elsa-core/src/samples/Elsa.Samples.HelloWorldConsole/Program.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2020-02-18 21:29:44 +00:00
using System;
using System.Threading.Tasks;
using Elsa.Activities.Console;
using Elsa.Builders;
using Elsa.Services;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Samples.HelloWorldConsole
{
class Program
{
static async Task Main(string[] args)
{
// Create a service container with Elsa services.
var services = new ServiceCollection()
.AddElsa()
.AddConsoleActivities()
.AddSingleton(Console.In)
.BuildServiceProvider();
// Build a new workflow.
var workflow = services.GetService<IWorkflowBuilder>()
.WriteLine("Hello World!")
.WriteLine("What's your name?")
.ReadLine()
2020-10-03 10:48:25 +00:00
.WriteLine(context => $"Greetings, {context.Input}!")
2020-02-18 21:29:44 +00:00
.Build();
// Get the workflow host.
var workflowHost = services.GetService<IWorkflowHost>();
// Execute the workflow.
await workflowHost.RunWorkflowAsync(workflow);
}
}
}