2022-11-20 19:37:56 +00:00
|
|
|
using Elsa.Workflows.Core;
|
|
|
|
|
using Elsa.Workflows.Core.Activities;
|
|
|
|
|
using Elsa.Workflows.Core.Models;
|
2022-11-21 21:01:52 +00:00
|
|
|
using Elsa.Workflows.Core.Services;
|
2022-11-20 19:37:56 +00:00
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
Root = new Sequence
|
|
|
|
|
{
|
2022-11-21 21:01:52 +00:00
|
|
|
Variables = new List<Variable>{ _name },
|
|
|
|
|
Activities = new List<IActivity>()
|
|
|
|
|
{
|
|
|
|
|
new WriteLine(context => Prompt.Get(context)),
|
|
|
|
|
new ReadLine(_name)
|
|
|
|
|
}
|
2022-11-20 19:37:56 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnCompleted(ActivityExecutionContext context, ActivityExecutionContext childContext)
|
|
|
|
|
{
|
|
|
|
|
var name = _name.Get<string>(context);
|
|
|
|
|
context.Set(Result, name);
|
|
|
|
|
}
|
|
|
|
|
}
|