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()
|
2020-10-18 15:05:48 +00:00
|
|
|
|
.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.
|
2020-10-23 12:22:24 +00:00
|
|
|
|
var workflowRunner = services.GetService<IWorkflowRunner>();
|
2020-02-18 21:29:44 +00:00
|
|
|
|
|
2020-11-03 08:46:38 +00:00
|
|
|
|
// Run the workflow.
|
2020-10-23 12:22:24 +00:00
|
|
|
|
await workflowRunner.RunWorkflowAsync<HelloWorld>();
|
2020-02-18 21:29:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|