2020-12-11 20:03:49 +00:00
|
|
|
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.
|
2020-12-02 21:20:13 +00:00
|
|
|
var workflowRunner = services.GetRequiredService<IWorkflowRunner>();
|
2020-11-01 19:03:21 +00:00
|
|
|
|
|
|
|
|
// Execute the workflow.
|
|
|
|
|
await workflowRunner.RunWorkflowAsync<CompositionWorkflow>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|