elsa-core/src/samples/console/Elsa.Samples.ConsoleApp.Composition/Activities/AskName.cs
Sipke Schoorstra 523f301bf7
Feature: Alterations (#4501)
* Implement Alteration types and engine

* Implement Alteration APIs

* Refactor activity work item with support for activity input

* Serialize scheduled activities as part of workflow state

* Add signal to schedule child activity

* Implement stores for plans and jobs

* Add EF Core provider

* Add Retry endpoint

* Keep root context as always active. The root context is the workflow execution context and contains persistent variable state

* Regenerate EF Core migrations

* Handle orphaned activity execution contexts

* Refactor workflow execution factory

* Enable configuring Jint from Program

* Update ModifyVariable alteration with support for type deserialization

* Use ShortGuid for identity

* Cleanup WorkflowServer host
2023-10-07 12:47:36 +02:00

34 lines
935 B
C#

using Elsa.Extensions;
using Elsa.Workflows.Core;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Contracts;
using Elsa.Workflows.Core.Memory;
using Elsa.Workflows.Core.Models;
namespace Elsa.Samples.ConsoleApp.Composition.Activities;
public class AskName : Composite<string>
{
private readonly Variable<string> _name = new();
public Input<string> Prompt { get; set; } = new("Please tell me your name:");
public AskName()
{
Variables = new List<Variable> { _name };
Root = new Sequence
{
Activities = new List<IActivity>
{
new WriteLine(context => Prompt.Get(context)),
new ReadLine(_name)
}
};
}
protected override void OnCompleted(ActivityCompletedContext context)
{
var name = _name.Get<string>(context.TargetContext);
context.TargetContext.Set(Result, name);
}
}