Skip to content

Commit

Permalink
Simplify Sample04
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmskywalker committed Oct 16, 2020
1 parent ca9f89a commit 00e6df0
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 29 deletions.
10 changes: 1 addition & 9 deletions src/samples/Sample04/Activities/ArithmeticOperation.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<double[]> Values
{
get => GetState<WorkflowExpression<double[]>>();
Expand All @@ -31,7 +23,7 @@ public string ResultVariableName

protected override async Task<ActivityExecutionResult> 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);
Expand Down
5 changes: 0 additions & 5 deletions src/samples/Sample04/Activities/Divide.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
5 changes: 0 additions & 5 deletions src/samples/Sample04/Activities/Multiply.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
5 changes: 0 additions & 5 deletions src/samples/Sample04/Activities/Subtract.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
5 changes: 0 additions & 5 deletions src/samples/Sample04/Activities/Sum.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 00e6df0

Please sign in to comment.