From e3bb394a03bc609b749c41f7a2ed3783c9abf9ee Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 11 Feb 2021 11:01:57 +0100 Subject: [PATCH] Update ForEach to not store a copy of the list Instead, rely on the Items property being set before each new iteration (which happens by default) --- .../Activities/ControlFlow/ForEach/ForEach.cs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/core/Elsa.Core/Activities/ControlFlow/ForEach/ForEach.cs b/src/core/Elsa.Core/Activities/ControlFlow/ForEach/ForEach.cs index cb125a52d..e7387a0c1 100644 --- a/src/core/Elsa.Core/Activities/ControlFlow/ForEach/ForEach.cs +++ b/src/core/Elsa.Core/Activities/ControlFlow/ForEach/ForEach.cs @@ -18,13 +18,7 @@ namespace Elsa.Activities.ControlFlow { [ActivityProperty(Hint = "Enter an expression that evaluates to a collection of items to iterate over.")] public ICollection Items { get; set; } = new Collection(); - - private IList? ItemsCopy - { - get => GetState>(); - set => SetState(value); - } - + private int? CurrentIndex { get => GetState(); @@ -33,11 +27,7 @@ namespace Elsa.Activities.ControlFlow protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context) { - var collection = ItemsCopy; - - if (collection == null) - ItemsCopy = collection = Items.ToList(); - + var collection = Items.ToList(); var currentIndex = CurrentIndex ?? 0; if (currentIndex < collection.Count) @@ -49,7 +39,6 @@ namespace Elsa.Activities.ControlFlow } CurrentIndex = null; - ItemsCopy = null; return Done(); } }