using Elsa.Extensions; using Elsa.Samples.ConsoleApp.CustomActivities.Activities; using Elsa.Workflows.Activities; using Elsa.Workflows.Contracts; using Elsa.Workflows.Memory; using Microsoft.Extensions.DependencyInjection; // Setup service container. var services = new ServiceCollection(); // Add Elsa services. services.AddElsa(); // Build service container. var serviceProvider = services.BuildServiceProvider(); // Resolve a workflow runner to run the workflow. var workflowRunner = serviceProvider.GetRequiredService(); // Create a workflow. var a = new Variable(); var b = new Variable(); var sum = new Variable(); var workflow = new Workflow { Root = new Sequence { Variables = {a, b, sum}, Activities = { new WriteLine("Enter first value"), new ReadLine(a), new WriteLine("Enter second value"), new ReadLine(b), new Sum(a, b, sum), new WriteLine(context => $"The sum of {a.Get(context)} and {b.Get(context)} is {sum.Get(context)}") } } }; // Run the workflow. await workflowRunner.RunAsync(workflow);