From 00e6df0d97d471b2abc4faed52b526a281a9340e Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 16 Oct 2020 13:21:23 +0200 Subject: [PATCH] Simplify Sample04 --- src/samples/Sample04/Activities/ArithmeticOperation.cs | 10 +--------- src/samples/Sample04/Activities/Divide.cs | 5 ----- src/samples/Sample04/Activities/Multiply.cs | 5 ----- src/samples/Sample04/Activities/Subtract.cs | 5 ----- src/samples/Sample04/Activities/Sum.cs | 5 ----- 5 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/samples/Sample04/Activities/ArithmeticOperation.cs b/src/samples/Sample04/Activities/ArithmeticOperation.cs index d00c3e3858..24f2a7b5e2 100644 --- a/src/samples/Sample04/Activities/ArithmeticOperation.cs +++ b/src/samples/Sample04/Activities/ArithmeticOperation.cs @@ -1,7 +1,6 @@ using System.Threading; using System.Threading.Tasks; using Elsa.Expressions; -using Elsa.Extensions; using Elsa.Services; using Elsa.Results; using Elsa.Services.Models; @@ -10,13 +9,6 @@ namespace Sample04.Activities { public abstract class ArithmeticOperation : Activity { - private readonly IWorkflowExpressionEvaluator evaluator; - - protected ArithmeticOperation(IWorkflowExpressionEvaluator evaluator) - { - this.evaluator = evaluator; - } - public WorkflowExpression Values { get => GetState>(); @@ -31,7 +23,7 @@ public string ResultVariableName protected override async Task OnExecuteAsync(WorkflowExecutionContext context, CancellationToken cancellationToken) { - var values = await evaluator.EvaluateAsync(Values, context, cancellationToken); + var values = await context.EvaluateAsync(Values, cancellationToken); var sum = Calculate(values); context.SetLastResult(sum); diff --git a/src/samples/Sample04/Activities/Divide.cs b/src/samples/Sample04/Activities/Divide.cs index e3868624de..d2d40a73c1 100644 --- a/src/samples/Sample04/Activities/Divide.cs +++ b/src/samples/Sample04/Activities/Divide.cs @@ -1,14 +1,9 @@ using System.Linq; -using Elsa.Services; namespace Sample04.Activities { public class Divide : ArithmeticOperation { - public Divide(IWorkflowExpressionEvaluator evaluator) : base(evaluator) - { - } - protected override double Calculate(params double[] values) => values.Aggregate((left, right) => left / right); } } \ No newline at end of file diff --git a/src/samples/Sample04/Activities/Multiply.cs b/src/samples/Sample04/Activities/Multiply.cs index 2073134b33..dec62f74d4 100644 --- a/src/samples/Sample04/Activities/Multiply.cs +++ b/src/samples/Sample04/Activities/Multiply.cs @@ -1,14 +1,9 @@ using System.Linq; -using Elsa.Services; namespace Sample04.Activities { public class Multiply : ArithmeticOperation { - public Multiply(IWorkflowExpressionEvaluator evaluator) : base(evaluator) - { - } - protected override double Calculate(params double[] values) => values.Aggregate((left, right) => left * right); } } \ No newline at end of file diff --git a/src/samples/Sample04/Activities/Subtract.cs b/src/samples/Sample04/Activities/Subtract.cs index 68e9ff62b2..987202c516 100644 --- a/src/samples/Sample04/Activities/Subtract.cs +++ b/src/samples/Sample04/Activities/Subtract.cs @@ -1,14 +1,9 @@ using System.Linq; -using Elsa.Services; namespace Sample04.Activities { public class Subtract : ArithmeticOperation { - public Subtract(IWorkflowExpressionEvaluator evaluator) : base(evaluator) - { - } - protected override double Calculate(params double[] values) => values.Aggregate((left, right) => left - right); } } \ No newline at end of file diff --git a/src/samples/Sample04/Activities/Sum.cs b/src/samples/Sample04/Activities/Sum.cs index e00412c51d..99a10cf4f7 100644 --- a/src/samples/Sample04/Activities/Sum.cs +++ b/src/samples/Sample04/Activities/Sum.cs @@ -1,14 +1,9 @@ using System.Linq; -using Elsa.Services; namespace Sample04.Activities { public class Sum : ArithmeticOperation { - public Sum(IWorkflowExpressionEvaluator evaluator) : base(evaluator) - { - } - protected override double Calculate(params double[] values) => values.Sum(); } } \ No newline at end of file