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

34 lines
1.2 KiB
C#
Raw Normal View History

using System.Threading.Tasks;
using Elsa.Persistence.InMemory;
2020-11-02 18:07:17 +00:00
using Elsa.Samples.ProgrammaticCompositeActivitiesConsole.Activities;
using Elsa.Samples.ProgrammaticCompositeActivitiesConsole.Workflows;
2020-11-01 19:03:21 +00:00
using Elsa.Services;
using Microsoft.Extensions.DependencyInjection;
2020-11-02 18:07:17 +00:00
namespace Elsa.Samples.ProgrammaticCompositeActivitiesConsole
2020-11-01 19:03:21 +00:00
{
class Program
{
static async Task Main(string[] args)
{
// Create a service container with Elsa services.
var services = new ServiceCollection()
2020-11-03 08:46:38 +00:00
.AddElsa()
2020-11-01 19:03:21 +00:00
.AddConsoleActivities()
.AddActivity<CountDownActivity>()
.AddWorkflow<CompositionWorkflow>()
.BuildServiceProvider();
// Run startup actions (not needed when registering Elsa with a Host).
var startupRunner = services.GetRequiredService<IStartupRunner>();
await startupRunner.StartupAsync();
// Get a workflow host.
var workflowRunner = services.GetRequiredService<IWorkflowRunner>();
2020-11-01 19:03:21 +00:00
// Execute the workflow.
await workflowRunner.RunWorkflowAsync<CompositionWorkflow>();
}
}
}