2022-05-26 10:47:31 +00:00
|
|
|
using Elsa.Workflows.Core.Activities;
|
|
|
|
|
using Elsa.Workflows.Core.Models;
|
|
|
|
|
using Elsa.Workflows.Core.Services;
|
2022-04-20 13:36:58 +00:00
|
|
|
|
2022-04-20 13:52:51 +00:00
|
|
|
namespace Elsa.IntegrationTests.Activities;
|
2022-04-20 13:36:58 +00:00
|
|
|
|
2022-04-30 09:10:08 +00:00
|
|
|
public class BreakWhileWorkflow : WorkflowBase
|
2022-04-20 13:36:58 +00:00
|
|
|
{
|
2022-08-25 11:45:35 +00:00
|
|
|
protected override void Build(IWorkflowBuilder workflow)
|
2022-04-20 13:36:58 +00:00
|
|
|
{
|
|
|
|
|
var currentValue = new Variable<int?>(0);
|
|
|
|
|
|
|
|
|
|
workflow.WithRoot(new Sequence
|
|
|
|
|
{
|
|
|
|
|
Variables = { currentValue },
|
|
|
|
|
Activities =
|
|
|
|
|
{
|
|
|
|
|
new WriteLine("Start"),
|
|
|
|
|
While.True(new Sequence
|
|
|
|
|
{
|
|
|
|
|
Activities =
|
|
|
|
|
{
|
|
|
|
|
new SetVariable
|
|
|
|
|
{
|
|
|
|
|
Variable = currentValue,
|
|
|
|
|
Value = new Input<object?>(context => currentValue.Get(context) + 1)
|
|
|
|
|
},
|
|
|
|
|
new If(context => currentValue.Get(context) == 3)
|
|
|
|
|
{
|
|
|
|
|
Then = new Break()
|
|
|
|
|
},
|
|
|
|
|
new WriteLine(context => currentValue.Get(context).ToString()),
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
new WriteLine("End"),
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|