Enhance: Add isStart property to determine if current node is a start node. (#5040)
This commit is contained in:
parent
519ab07a1c
commit
cef0cceef0
|
|
@ -82,6 +82,11 @@ public record ActivityDescriptor
|
|||
/// </summary>
|
||||
public bool IsBrowsable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this activity type is a start activity.
|
||||
/// </summary>
|
||||
public bool IsStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this activity type is a terminal activity.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using Elsa.Workflows.Attributes;
|
||||
using Elsa.Workflows.Contracts;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Workflows.Activities;
|
||||
|
|
@ -9,7 +10,7 @@ namespace Elsa.Workflows.Activities;
|
|||
/// </summary>
|
||||
[Activity("Elsa", "Flow", "A milestone activity that marks the start of a flowchart.", Kind = ActivityKind.Action)]
|
||||
[PublicAPI]
|
||||
public class Start : CodeActivity
|
||||
public class Start : CodeActivity, IStartNode
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public Start([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
|
||||
|
|
|
|||
8
src/modules/Elsa.Workflows.Core/Contracts/IStartNode.cs
Normal file
8
src/modules/Elsa.Workflows.Core/Contracts/IStartNode.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
namespace Elsa.Workflows.Contracts;
|
||||
|
||||
/// <summary>
|
||||
/// Marks an activity as a terminal activity.
|
||||
/// </summary>
|
||||
public interface IStartNode
|
||||
{
|
||||
}
|
||||
|
|
@ -97,6 +97,11 @@ public class ActivityDescriptor
|
|||
/// </summary>
|
||||
public bool IsBrowsable { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this activity type is a start activity.
|
||||
/// </summary>
|
||||
public bool IsStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this activity type is a terminal activity.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ public class ActivityDescriber : IActivityDescriber
|
|||
var isTrigger = activityType.IsAssignableTo(typeof(ITrigger));
|
||||
var browsableAttr = activityType.GetCustomAttribute<BrowsableAttribute>();
|
||||
var isTerminal = activityType.FindInterfaces((type, criteria) => type == typeof(ITerminalNode), null).Any();
|
||||
var isStart = activityType.FindInterfaces((type, criteria) => type == typeof(IStartNode), null).Any();
|
||||
var attributes = activityType.GetCustomAttributes(true).Cast<Attribute>().ToList();
|
||||
var outputAttribute = attributes.OfType<OutputAttribute>().FirstOrDefault();
|
||||
|
||||
|
|
@ -92,6 +93,7 @@ public class ActivityDescriber : IActivityDescriber
|
|||
Outputs = (await DescribeOutputPropertiesAsync(outputProperties, cancellationToken)).ToList(),
|
||||
IsContainer = typeof(IContainer).IsAssignableFrom(activityType),
|
||||
IsBrowsable = browsableAttr == null || browsableAttr.Browsable,
|
||||
IsStart = isStart,
|
||||
IsTerminal = isTerminal,
|
||||
Attributes = attributes,
|
||||
Constructor = context =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue