parent
cb4637fe19
commit
e52c4eb91f
|
|
@ -6,12 +6,12 @@ namespace Elsa.Workflows.Core.Models;
|
|||
public class ActivityOutputRegister
|
||||
{
|
||||
private readonly ICollection<ActivityOutputRecord> _records = new List<ActivityOutputRecord>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The default output name.
|
||||
/// </summary>
|
||||
public const string DefaultOutputName = "Result";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Records an activity's output.
|
||||
/// </summary>
|
||||
|
|
@ -21,7 +21,7 @@ public class ActivityOutputRegister
|
|||
{
|
||||
Record(activityExecutionContext, default, outputValue);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Records an activity's output.
|
||||
/// </summary>
|
||||
|
|
@ -33,18 +33,26 @@ public class ActivityOutputRegister
|
|||
var activityId = activityExecutionContext.Activity.Id;
|
||||
var activityInstanceId = activityExecutionContext.Id;
|
||||
var containerId = activityExecutionContext.ParentActivityExecutionContext?.Id ?? activityExecutionContext.WorkflowExecutionContext.Id;
|
||||
|
||||
|
||||
outputName ??= DefaultOutputName;
|
||||
var record = new ActivityOutputRecord(containerId, activityId, activityInstanceId, outputName, outputValue);
|
||||
|
||||
// Inspect the output descriptor to see if the specified output name matches any PropertyInfo's name.
|
||||
// If so, use that descriptor's name instead.
|
||||
var outputDescriptor = activityExecutionContext.ActivityDescriptor.Outputs.FirstOrDefault(x => x.PropertyInfo?.Name == outputName);
|
||||
|
||||
if (outputDescriptor != null)
|
||||
outputName = outputDescriptor.Name;
|
||||
|
||||
var record = new ActivityOutputRecord(containerId, activityId, activityInstanceId, outputName, outputValue);
|
||||
|
||||
_records.Add(record);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds all output records matching the specified predicate.
|
||||
/// </summary>
|
||||
public IEnumerable<ActivityOutputRecord> FindMany(Func<ActivityOutputRecord, bool> predicate) => _records.Where(predicate);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the output value for the specified activity ID.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Reflection;
|
||||
using Elsa.Workflows.Core.Contracts;
|
||||
|
||||
namespace Elsa.Workflows.Core.Models;
|
||||
|
|
@ -30,7 +31,8 @@ public class InputDescriptor : PropertyDescriptor
|
|||
bool isReadOnly = false,
|
||||
bool isBrowsable = true,
|
||||
bool isSynthetic = false,
|
||||
Type? storageDriverType = default)
|
||||
Type? storageDriverType = default,
|
||||
PropertyInfo? propertyInfo = default)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
|
|
@ -45,11 +47,11 @@ public class InputDescriptor : PropertyDescriptor
|
|||
Order = order;
|
||||
DefaultValue = defaultValue;
|
||||
DefaultSyntax = defaultSyntax;
|
||||
//SupportedSyntaxes = supportedSyntaxes?.ToList() ?? new List<string>();
|
||||
IsReadOnly = isReadOnly;
|
||||
StorageDriverType = storageDriverType;
|
||||
IsSynthetic = isSynthetic;
|
||||
IsBrowsable = isBrowsable;
|
||||
PropertyInfo = propertyInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -81,7 +83,6 @@ public class InputDescriptor : PropertyDescriptor
|
|||
/// The default syntax.
|
||||
/// </summary>
|
||||
public string? DefaultSyntax { get; set; }
|
||||
//public ICollection<string> SupportedSyntaxes { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// True if the input is readonly, false otherwise.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Reflection;
|
||||
using System.Text.Json.Serialization;
|
||||
using Elsa.Workflows.Core.Contracts;
|
||||
|
||||
|
|
@ -21,8 +22,8 @@ public class OutputDescriptor : PropertyDescriptor
|
|||
Type type,
|
||||
Func<IActivity, object?> valueGetter,
|
||||
Action<IActivity, object?> valueSetter,
|
||||
|
||||
string? description = default,
|
||||
PropertyInfo? propertyInfo = default,
|
||||
string? description = default,
|
||||
bool? isBrowsable = default)
|
||||
{
|
||||
Name = name;
|
||||
|
|
@ -32,5 +33,6 @@ public class OutputDescriptor : PropertyDescriptor
|
|||
ValueSetter = valueSetter;
|
||||
Description = description;
|
||||
IsBrowsable = isBrowsable;
|
||||
PropertyInfo = propertyInfo;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Reflection;
|
||||
using System.Text.Json.Serialization;
|
||||
using Elsa.Workflows.Core.Contracts;
|
||||
|
||||
|
|
@ -55,4 +56,10 @@ public abstract class PropertyDescriptor
|
|||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Action<IActivity, object?> ValueSetter { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The source of the property, if any.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public PropertyInfo? PropertyInfo { get; set; }
|
||||
}
|
||||
|
|
@ -125,6 +125,7 @@ public class ActivityDescriber : IActivityDescriber
|
|||
wrappedPropertyType,
|
||||
propertyInfo.GetValue,
|
||||
propertyInfo.SetValue,
|
||||
propertyInfo,
|
||||
descriptionAttribute?.Description ?? outputAttribute?.Description,
|
||||
outputAttribute?.IsBrowsable ?? true
|
||||
));
|
||||
|
|
@ -160,7 +161,10 @@ public class ActivityDescriber : IActivityDescriber
|
|||
_defaultValueResolver.GetDefaultValue(propertyInfo),
|
||||
inputAttribute?.DefaultSyntax,
|
||||
inputAttribute?.IsReadOnly ?? false,
|
||||
inputAttribute?.IsBrowsable ?? true
|
||||
inputAttribute?.IsBrowsable ?? true,
|
||||
false,
|
||||
default,
|
||||
propertyInfo
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue