| | | 1 | | namespace Elsa.Workflows.Management.Options; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents the options for managing host method-based activities in workflows. |
| | | 5 | | /// </summary> |
| | | 6 | | public class HostMethodActivitiesOptions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Maps a registration key to a CLR type whose public async methods should be exposed as activities. |
| | | 10 | | /// </summary> |
| | 35 | 11 | | public IDictionary<string, Type> ActivityTypes { get; } = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreC |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Adds a new activity type to the collection of activity types. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <typeparam name="T">The type of the activity to add.</typeparam> |
| | | 17 | | /// <param name="key">An optional key to associate with the activity type. If not provided, the type's name will be |
| | | 18 | | public HostMethodActivitiesOptions AddType<T>(string? key = null) where T : class |
| | | 19 | | { |
| | 14 | 20 | | key ??= typeof(T).Name; |
| | 14 | 21 | | ActivityTypes[key] = typeof(T); |
| | 14 | 22 | | return this; |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Adds a new activity type to the collection of activity types. |
| | | 27 | | /// </summary> |
| | | 28 | | /// <param name="type">The type of the activity to add.</param> |
| | | 29 | | /// <param name="key">An optional key to associate with the activity type. If not provided, the type's name will be |
| | | 30 | | public HostMethodActivitiesOptions AddType(Type type, string? key = null) |
| | | 31 | | { |
| | 0 | 32 | | key ??= type.Name; |
| | 0 | 33 | | ActivityTypes[key] = type; |
| | 0 | 34 | | return this; |
| | | 35 | | } |
| | | 36 | | } |