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

29 lines
953 B
C#
Raw Normal View History

2020-11-03 09:18:19 +00:00
using System.Threading.Tasks;
2020-02-18 21:29:44 +00:00
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.
2020-10-10 20:14:10 +00:00
var services = new ServiceCollection()
2020-02-18 21:29:44 +00:00
.AddElsa()
.AddConsoleActivities()
.AddWorkflow<HelloWorld>()
2020-02-18 21:29:44 +00:00
.BuildServiceProvider();
2020-10-10 19:10:09 +00:00
// Run startup actions (not needed when registering Elsa with a Host).
var startupRunner = services.GetRequiredService<IStartupRunner>();
await startupRunner.StartupAsync();
2020-11-03 08:46:38 +00:00
// Get a workflow runner.
var workflowRunner = services.GetService<IWorkflowRunner>();
2020-02-18 21:29:44 +00:00
2020-11-03 08:46:38 +00:00
// Run the workflow.
await workflowRunner.RunWorkflowAsync<HelloWorld>();
2020-02-18 21:29:44 +00:00
}
}
}