| | | 1 | | namespace Elsa.Workflows; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents an activity that acts as a workflow trigger. |
| | | 5 | | /// </summary> |
| | | 6 | | public abstract class Trigger : Activity, ITrigger |
| | | 7 | | { |
| | | 8 | | /// <inheritdoc /> |
| | | 9 | | protected Trigger(string? source = null, int? line = null) : base(source, line) |
| | | 10 | | { |
| | | 11 | | } |
| | | 12 | | |
| | | 13 | | /// <inheritdoc /> |
| | | 14 | | protected Trigger(string activityType, int version = 1, string? source = null, int? line = null) : base(activityType |
| | | 15 | | { |
| | | 16 | | } |
| | | 17 | | |
| | | 18 | | ValueTask<IEnumerable<object>> ITrigger.GetTriggerPayloadsAsync(TriggerIndexingContext context) => GetTriggerPayload |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Override this method to return trigger data. |
| | | 22 | | /// </summary> |
| | | 23 | | protected virtual ValueTask<IEnumerable<object>> GetTriggerPayloadsAsync(TriggerIndexingContext context) |
| | | 24 | | { |
| | | 25 | | var hashes = GetTriggerPayloads(context); |
| | | 26 | | return ValueTask.FromResult(hashes); |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Override this method to return trigger data. |
| | | 31 | | /// </summary> |
| | | 32 | | protected virtual IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context) => [GetTriggerPayload(conte |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Override this method to return a trigger datum. |
| | | 36 | | /// </summary> |
| | | 37 | | protected virtual object GetTriggerPayload(TriggerIndexingContext context) => new(); |
| | | 38 | | } |
| | | 39 | | |
| | | 40 | | public abstract class Trigger<TResult> : Activity<TResult>, ITrigger |
| | | 41 | | { |
| | 411 | 42 | | protected Trigger(string? source = null, int? line = null) : base(source, line) |
| | | 43 | | { |
| | 411 | 44 | | } |
| | | 45 | | |
| | 0 | 46 | | protected Trigger(string activityType, int version = 1, string? source = null, int? line = null) : base(activityType |
| | | 47 | | { |
| | 0 | 48 | | } |
| | | 49 | | |
| | 61 | 50 | | ValueTask<IEnumerable<object>> ITrigger.GetTriggerPayloadsAsync(TriggerIndexingContext context) => GetTriggerPayload |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// Override this method to return trigger data. |
| | | 54 | | /// </summary> |
| | | 55 | | protected virtual ValueTask<IEnumerable<object>> GetTriggerPayloadsAsync(TriggerIndexingContext context) |
| | | 56 | | { |
| | 61 | 57 | | var hashes = GetTriggerPayloads(context); |
| | 61 | 58 | | return ValueTask.FromResult(hashes); |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Override this method to return a trigger payload. |
| | | 63 | | /// </summary> |
| | 14 | 64 | | protected virtual IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context) => [GetTriggerPayload(conte |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Override this method to return a trigger payload. |
| | | 68 | | /// </summary> |
| | 0 | 69 | | protected virtual object GetTriggerPayload(TriggerIndexingContext context) => new(); |
| | | 70 | | } |