2020-12-11 20:03:49 +00:00
|
|
|
using System.Threading.Tasks;
|
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;
|
2021-01-03 10:06:11 +00:00
|
|
|
using Microsoft.Extensions.Logging;
|
2020-11-01 19:03:21 +00:00
|
|
|
|
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()
|
2021-01-03 10:06:11 +00:00
|
|
|
.AddLogging(logging => logging.AddConsole())
|
2020-12-26 11:21:08 +00:00
|
|
|
.AddElsa(options => options
|
|
|
|
|
.AddConsoleActivities()
|
2021-01-03 10:06:11 +00:00
|
|
|
.AddActivity<NavigateActivity>()
|
|
|
|
|
.AddActivity<CountdownActivity>()
|
2020-12-26 11:21:08 +00:00
|
|
|
.AddWorkflow<CompositionWorkflow>())
|
2020-11-01 19:03:21 +00:00
|
|
|
.BuildServiceProvider();
|
2020-12-26 11:21:08 +00:00
|
|
|
|
2020-11-01 19:03:21 +00:00
|
|
|
// Run startup actions (not needed when registering Elsa with a Host).
|
|
|
|
|
var startupRunner = services.GetRequiredService<IStartupRunner>();
|
|
|
|
|
await startupRunner.StartupAsync();
|
2020-12-26 11:21:08 +00:00
|
|
|
|
2020-11-01 19:03:21 +00:00
|
|
|
// 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>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|