| | | 1 | | using Elsa.Extensions; |
| | | 2 | | using Elsa.Workflows.Models; |
| | | 3 | | |
| | | 4 | | namespace Elsa.Workflows; |
| | | 5 | | |
| | | 6 | | public static class ActivityExecutionContextExtensions |
| | | 7 | | { |
| | | 8 | | extension(ActivityExecutionContext context) |
| | | 9 | | { |
| | | 10 | | public IDictionary<string, object> GetInputs() |
| | | 11 | | { |
| | 3130 | 12 | | return context.ActivityState!; |
| | | 13 | | } |
| | | 14 | | |
| | | 15 | | public IDictionary<string, object> GetOutputs() |
| | | 16 | | { |
| | 3130 | 17 | | var activity = context.Activity; |
| | 3130 | 18 | | var expressionExecutionContext = context.ExpressionExecutionContext; |
| | 3130 | 19 | | var activityDescriptor = context.ActivityDescriptor; |
| | 3130 | 20 | | var outputDescriptors = activityDescriptor.Outputs; |
| | | 21 | | |
| | 5651 | 22 | | var outputs = outputDescriptors.ToDictionary(x => x.Name, x => |
| | 3130 | 23 | | { |
| | 2521 | 24 | | if (x.IsSerializable == false) |
| | 703 | 25 | | return "(not serializable)"; |
| | 3130 | 26 | | |
| | 1818 | 27 | | var cachedValue = activity.GetOutput(expressionExecutionContext, x.Name); |
| | 3130 | 28 | | |
| | 1818 | 29 | | if (cachedValue != null) |
| | 926 | 30 | | return cachedValue; |
| | 3130 | 31 | | |
| | 892 | 32 | | if (x.ValueGetter(activity) is Output output && context.TryGet(output.MemoryBlockReference(), out var ou |
| | 120 | 33 | | return outputValue!; |
| | 3130 | 34 | | |
| | 772 | 35 | | return null!; |
| | 3130 | 36 | | }); |
| | | 37 | | |
| | 3130 | 38 | | return outputs; |
| | | 39 | | } |
| | | 40 | | } |
| | | 41 | | } |