elsa-core/samples/console/Elsa.Samples.ConsoleApp.OutboundHttpRequests/Program.cs

24 lines
832 B
C#
Raw Normal View History

2023-01-23 14:59:06 +00:00
using Elsa.Extensions;
2023-06-08 10:01:26 +00:00
using Elsa.Samples.ConsoleApp.OutboundHttpRequests.Workflows;
using Elsa.Workflows;
using Microsoft.Extensions.Configuration;
2023-01-23 14:59:06 +00:00
using Microsoft.Extensions.DependencyInjection;
// Setup service container.
var services = new ServiceCollection();
// Manually construct configuration. Normally this is provided by the host builder, but this is a simple Console app.
var config = new ConfigurationBuilder().Build();
services.AddSingleton<IConfiguration>(config);
2023-01-23 14:59:06 +00:00
// Add Elsa services.
services.AddElsa(elsa => elsa.UseHttp());
// Build service container.
var serviceProvider = services.BuildServiceProvider();
// Resolve a workflow runner to run the workflow.
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();
// Run the workflow.
await workflowRunner.RunAsync<GetUsersWorkflow>();