2022-12-31 15:16:43 +00:00
|
|
|
using Elsa.Extensions;
|
2023-07-09 11:12:13 +00:00
|
|
|
using Elsa.Workflows.Core;
|
2022-11-20 19:37:56 +00:00
|
|
|
using Elsa.Workflows.Core.Activities;
|
2023-03-03 21:47:23 +00:00
|
|
|
using Elsa.Workflows.Core.Contracts;
|
2023-07-09 11:12:13 +00:00
|
|
|
using Elsa.Workflows.Core.Memory;
|
2022-11-20 19:37:56 +00:00
|
|
|
using Elsa.Workflows.Core.Models;
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
2023-05-16 09:41:41 +00:00
|
|
|
Variables = new List<Variable> { _name };
|
2022-11-20 19:37:56 +00:00
|
|
|
Root = new Sequence
|
|
|
|
|
{
|
2023-03-22 21:50:26 +00:00
|
|
|
Activities = new List<IActivity>
|
2022-11-24 20:12:07 +00:00
|
|
|
{
|
|
|
|
|
new WriteLine(context => Prompt.Get(context)),
|
|
|
|
|
new ReadLine(_name)
|
|
|
|
|
}
|
2022-11-20 19:37:56 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-25 23:11:10 +00:00
|
|
|
protected override void OnCompleted(ActivityCompletedContext context)
|
2022-11-20 19:37:56 +00:00
|
|
|
{
|
2023-08-25 23:11:10 +00:00
|
|
|
var name = _name.Get<string>(context.TargetContext);
|
|
|
|
|
context.TargetContext.Set(Result, name);
|
2022-11-20 19:37:56 +00:00
|
|
|
}
|
|
|
|
|
}
|