| | | 1 | | namespace Elsa.Workflows.Models; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// A trigger payload that carries its own stimulus name. |
| | | 5 | | /// </summary> |
| | | 6 | | /// <remarks> |
| | | 7 | | /// Return instances of this type from <see cref="ITrigger.GetTriggerPayloadsAsync"/> when a single trigger needs to reg |
| | | 8 | | /// more than one stimulus name. The wrapper is unwrapped during indexing: the stored trigger's name and hash are derive |
| | | 9 | | /// and its payload from <see cref="Payload"/>. Payloads that are not wrapped are named using <see cref="TriggerIndexing |
| | | 10 | | /// </remarks> |
| | | 11 | | public record NamedTriggerPayload |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Initializes a new instance of the <see cref="NamedTriggerPayload"/> class. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <param name="name">The stimulus name to register the payload under.</param> |
| | | 17 | | /// <param name="payload">The payload to register.</param> |
| | 0 | 18 | | public NamedTriggerPayload(string name, object payload) |
| | | 19 | | { |
| | 0 | 20 | | if (string.IsNullOrWhiteSpace(name)) |
| | 0 | 21 | | throw new ArgumentException("A stimulus name is required.", nameof(name)); |
| | | 22 | | |
| | 0 | 23 | | if (payload is NamedTriggerPayload) |
| | 0 | 24 | | throw new ArgumentException("A NamedTriggerPayload cannot wrap another NamedTriggerPayload.", nameof(payload |
| | | 25 | | |
| | 0 | 26 | | Name = name; |
| | 0 | 27 | | Payload = payload; |
| | 0 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// The stimulus name to register the payload under. Publishers of this stimulus compute their hash from this same n |
| | | 32 | | /// </summary> |
| | 0 | 33 | | public string Name { get; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// The payload to register. This is what gets stored; the wrapper itself never is, since the constructor refuses to |
| | | 37 | | /// <see cref="NamedTriggerPayload"/>. |
| | | 38 | | /// </summary> |
| | 0 | 39 | | public object Payload { get; } |
| | | 40 | | } |