| | | 1 | | using System.Diagnostics; |
| | | 2 | | using System.Text.Json; |
| | | 3 | | using System.Text.Json.Serialization; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Workflows.Models; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// A descriptor of an activity type. It also provides a constructor to create instances of this type. |
| | | 9 | | /// </summary> |
| | | 10 | | [DebuggerDisplay("{TypeName}")] |
| | | 11 | | public class ActivityDescriptor |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// The fully qualified name of the activity type. |
| | | 15 | | /// </summary> |
| | 206567 | 16 | | public string TypeName { get; set; } = null!; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// The .NET type of the activity type. |
| | | 20 | | /// </summary> |
| | 12741 | 21 | | public Type ClrType { get; set; } = null!; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// The namespace of the activity type. |
| | | 25 | | /// </summary> |
| | 11976 | 26 | | public string Namespace { get; set; } = null!; |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// The name of the activity type. |
| | | 30 | | /// </summary> |
| | 12741 | 31 | | public string Name { get; set; } = null!; |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// The version of the activity type. |
| | | 35 | | /// </summary> |
| | 43351 | 36 | | public int Version { get; set; } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// The category of the activity type. |
| | | 40 | | /// </summary> |
| | 12741 | 41 | | public string Category { get; set; } = null!; |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// The display name of the activity type. |
| | | 45 | | /// </summary> |
| | 12741 | 46 | | public string? DisplayName { get; set; } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// The description of the activity type. |
| | | 50 | | /// </summary> |
| | 12741 | 51 | | public string? Description { get; set; } |
| | | 52 | | |
| | | 53 | | /// <summary> |
| | | 54 | | /// The input properties of the activity type. |
| | | 55 | | /// </summary> |
| | 63209 | 56 | | public ICollection<InputDescriptor> Inputs { get; init; } = new List<InputDescriptor>(); |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// The output properties of the activity type. |
| | | 60 | | /// </summary> |
| | 50266 | 61 | | public ICollection<OutputDescriptor> Outputs { get; init; } = new List<OutputDescriptor>(); |
| | | 62 | | |
| | | 63 | | /// <summary> |
| | | 64 | | /// The attributes of the activity type. |
| | | 65 | | /// </summary> |
| | 24895 | 66 | | [JsonIgnore] public ICollection<Attribute> Attributes { get; set; } = new List<Attribute>(); |
| | | 67 | | |
| | | 68 | | /// <summary> |
| | | 69 | | /// Instantiates a concrete instance of an <see cref="IActivity"/>. |
| | | 70 | | /// </summary> |
| | | 71 | | [JsonIgnore] |
| | 15336 | 72 | | public Func<ActivityConstructorContext, IActivity> Constructor { get; set; } = null!; |
| | | 73 | | |
| | | 74 | | /// <summary> |
| | | 75 | | /// The kind of activity. |
| | | 76 | | /// </summary> |
| | 21749 | 77 | | public ActivityKind Kind { get; set; } = ActivityKind.Action; |
| | | 78 | | |
| | | 79 | | /// <summary> |
| | | 80 | | /// The ports of the activity type. |
| | | 81 | | /// </summary> |
| | 25482 | 82 | | public ICollection<Port> Ports { get; set; } = new List<Port>(); |
| | | 83 | | |
| | | 84 | | /// <summary> |
| | | 85 | | /// The custom properties of the activity type. |
| | | 86 | | /// </summary> |
| | 46714 | 87 | | public IDictionary<string, object> CustomProperties { get; set; } = new Dictionary<string, object>(); |
| | | 88 | | |
| | | 89 | | /// <summary> |
| | | 90 | | /// The properties to set when constructing an activity in the designer. |
| | | 91 | | /// </summary> |
| | 13506 | 92 | | public IDictionary<string, object> ConstructionProperties { get; set; } = new Dictionary<string, object>(); |
| | | 93 | | |
| | | 94 | | /// <summary> |
| | | 95 | | /// A value indicating whether this activity is a container of child activities. |
| | | 96 | | /// </summary> |
| | 11976 | 97 | | public bool IsContainer { get; set; } |
| | | 98 | | |
| | | 99 | | /// <summary> |
| | | 100 | | /// Whether this activity type is selectable from activity pickers. |
| | | 101 | | /// </summary> |
| | 25483 | 102 | | public bool IsBrowsable { get; set; } = true; |
| | | 103 | | |
| | | 104 | | /// <summary> |
| | | 105 | | /// Whether this activity type is a start activity. |
| | | 106 | | /// </summary> |
| | 11976 | 107 | | public bool IsStart { get; set; } |
| | | 108 | | |
| | | 109 | | /// <summary> |
| | | 110 | | /// Whether this activity type is a terminal activity. |
| | | 111 | | /// </summary> |
| | 11976 | 112 | | public bool IsTerminal { get; set; } |
| | | 113 | | |
| | | 114 | | /// <summary> |
| | | 115 | | /// Gets or sets a function that allows configuring the JsonSerializerOptions for the activity during serialization. |
| | | 116 | | /// </summary> |
| | | 117 | | /// <remarks> |
| | | 118 | | /// This function can be used to customize the serialization options for an activity. It receives a JsonSerializerOp |
| | | 119 | | /// object as an argument and should return the modified JsonSerializerOptions. |
| | | 120 | | /// <para>Example:</para> |
| | | 121 | | /// <code> |
| | | 122 | | /// activityDescriptor.ConfigureSerializerOptions = options => |
| | | 123 | | /// { |
| | | 124 | | /// options.Converters.Add(new JsonIgnoreCompositeRootConverterFactory()); |
| | | 125 | | /// return options; |
| | | 126 | | /// }; |
| | | 127 | | /// </code> |
| | | 128 | | /// </remarks> |
| | | 129 | | [JsonIgnore] |
| | 1150 | 130 | | public Func<JsonSerializerOptions, JsonSerializerOptions>? ConfigureSerializerOptions { get; set; } |
| | | 131 | | } |