| | | 1 | | using Elsa.Expressions.Models; |
| | | 2 | | using Elsa.Extensions; |
| | | 3 | | using Elsa.Workflows.Attributes; |
| | | 4 | | using Elsa.Workflows.Behaviors; |
| | | 5 | | using Elsa.Workflows.Models; |
| | | 6 | | using JetBrains.Annotations; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Workflows; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Base class for custom activities with auto-complete behavior. |
| | | 12 | | /// </summary> |
| | | 13 | | [PublicAPI] |
| | | 14 | | public abstract class CodeActivity : Activity |
| | | 15 | | { |
| | | 16 | | /// <inheritdoc /> |
| | | 17 | | protected CodeActivity(string? source = default, int? line = default) : base(source, line) |
| | | 18 | | { |
| | | 19 | | Behaviors.Add<AutoCompleteBehavior>(this); |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <inheritdoc /> |
| | | 23 | | protected CodeActivity(string activityType, int version = 1, string? source = default, int? line = default) : base(a |
| | | 24 | | { |
| | | 25 | | Type = activityType; |
| | | 26 | | } |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Base class for custom activities with auto-complete behavior that return a result. |
| | | 31 | | /// </summary> |
| | | 32 | | [PublicAPI] |
| | | 33 | | public abstract class CodeActivityWithResult : CodeActivity |
| | | 34 | | { |
| | | 35 | | /// <inheritdoc /> |
| | 0 | 36 | | protected CodeActivityWithResult(string? source = default, int? line = default) : base(source, line) |
| | | 37 | | { |
| | 0 | 38 | | } |
| | | 39 | | |
| | | 40 | | /// <inheritdoc /> |
| | 0 | 41 | | protected CodeActivityWithResult(string activityType, int version = 1, string? source = default, int? line = default |
| | | 42 | | { |
| | 0 | 43 | | } |
| | | 44 | | |
| | | 45 | | /// <inheritdoc /> |
| | 0 | 46 | | protected CodeActivityWithResult(MemoryBlockReference? output, string? source = default, int? line = default) : base |
| | | 47 | | { |
| | 0 | 48 | | if (output != null) Result = new Output(output); |
| | 0 | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <inheritdoc /> |
| | 0 | 52 | | protected CodeActivityWithResult(Output? output, string? source = default, int? line = default) : base(source, line) |
| | | 53 | | { |
| | 0 | 54 | | Result = output; |
| | 0 | 55 | | } |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// The result of the activity. |
| | | 59 | | /// </summary> |
| | 0 | 60 | | public Output? Result { get; set; } |
| | | 61 | | } |
| | | 62 | | |
| | | 63 | | /// <summary> |
| | | 64 | | /// Base class for custom activities with auto-complete behavior that return a result. |
| | | 65 | | /// </summary> |
| | | 66 | | public abstract class CodeActivity<T> : CodeActivity, IActivityWithResult<T> |
| | | 67 | | { |
| | | 68 | | /// <inheritdoc /> |
| | | 69 | | protected CodeActivity(string? source = default, int? line = default) : base(source, line) |
| | | 70 | | { |
| | | 71 | | } |
| | | 72 | | |
| | | 73 | | /// <inheritdoc /> |
| | | 74 | | protected CodeActivity(string activityType, int version = 1, string? source = default, int? line = default) : base(a |
| | | 75 | | { |
| | | 76 | | } |
| | | 77 | | |
| | | 78 | | /// <inheritdoc /> |
| | | 79 | | protected CodeActivity(MemoryBlockReference? output, string? source = default, int? line = default) : this(source, l |
| | | 80 | | { |
| | | 81 | | if (output != null) Result = new Output<T>(output); |
| | | 82 | | } |
| | | 83 | | |
| | | 84 | | /// <inheritdoc /> |
| | | 85 | | protected CodeActivity(Output<T>? output, string? source = default, int? line = default) : this(source, line) |
| | | 86 | | { |
| | | 87 | | Result = output; |
| | | 88 | | } |
| | | 89 | | |
| | | 90 | | /// <summary> |
| | | 91 | | /// The result of the activity. |
| | | 92 | | /// </summary> |
| | | 93 | | [Output] public Output<T>? Result { get; set; } |
| | | 94 | | |
| | | 95 | | Output? IActivityWithResult.Result |
| | | 96 | | { |
| | | 97 | | get => Result; |
| | | 98 | | set => Result = (Output<T>?)value; |
| | | 99 | | } |
| | | 100 | | } |