2023-04-21 22:02:02 +00:00
|
|
|
using Elsa.Extensions;
|
2023-07-09 11:12:13 +00:00
|
|
|
using Elsa.Workflows.Core;
|
|
|
|
|
using Elsa.Workflows.Core.Memory;
|
2023-04-21 22:02:02 +00:00
|
|
|
using Elsa.Workflows.Core.Models;
|
|
|
|
|
|
2023-06-08 10:01:26 +00:00
|
|
|
namespace Elsa.Samples.ConsoleApp.CustomActivities.Activities;
|
2023-04-21 22:02:02 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sums two numbers.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Sum : CodeActivity<int>
|
|
|
|
|
{
|
|
|
|
|
public Sum(Variable<int> a, Variable<int> b, Variable<int> result)
|
|
|
|
|
{
|
|
|
|
|
A = new(a);
|
|
|
|
|
B = new(b);
|
|
|
|
|
Result = new(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Input<int> A { get; set; } = default!;
|
|
|
|
|
public Input<int> B { get; set; } = default!;
|
|
|
|
|
|
|
|
|
|
protected override void Execute(ActivityExecutionContext context)
|
|
|
|
|
{
|
|
|
|
|
var input1 = A.Get(context);
|
|
|
|
|
var input2 = B.Get(context);
|
|
|
|
|
var result = input1 + input2;
|
|
|
|
|
context.SetResult(result);
|
|
|
|
|
}
|
|
|
|
|
}
|