Merge remote-tracking branch 'origin/develop/3.6.0' into develop/3.6.0
This commit is contained in:
commit
4f4263e544
|
|
@ -0,0 +1,28 @@
|
|||
using System.Diagnostics;
|
||||
using Elsa.Expressions.Contracts;
|
||||
using Elsa.Expressions.Models;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Workflows.Memory;
|
||||
using Elsa.Workflows.Models;
|
||||
|
||||
namespace Elsa.Workflows.Expressions;
|
||||
|
||||
/// <summary>
|
||||
/// Handles Input expressions.
|
||||
/// </summary>
|
||||
public class InputExpressionHandler : IExpressionHandler
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public ValueTask<object?> EvaluateAsync(Expression expression, Type returnType, ExpressionExecutionContext context, ExpressionEvaluatorOptions options)
|
||||
{
|
||||
object? result = null;
|
||||
var inputDefinition = expression.Value as InputDefinition;
|
||||
|
||||
if (inputDefinition != null)
|
||||
{
|
||||
result = context.GetInput(inputDefinition.Name);
|
||||
}
|
||||
|
||||
return ValueTask.FromResult(result);
|
||||
}
|
||||
}
|
||||
|
|
@ -199,6 +199,9 @@ public class ActivityDescriber(IPropertyDefaultValueResolver defaultValueResolve
|
|||
if (wrappedPropertyType == typeof(Variable))
|
||||
return InputUIHints.VariablePicker;
|
||||
|
||||
if (wrappedPropertyType == typeof(WorkflowInput))
|
||||
return InputUIHints.InputPicker;
|
||||
|
||||
if (wrappedPropertyType == typeof(Type))
|
||||
return InputUIHints.TypePicker;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@ public static class InputUIHints
|
|||
public const string SingleLine = "singleline";
|
||||
public const string TypePicker = "type-picker";
|
||||
public const string VariablePicker = "variable-picker";
|
||||
public const string InputPicker = "input-picker";
|
||||
public const string WorkflowDefinitionPicker = "workflow-definition-picker";
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Expressions.Contracts;
|
||||
|
|
@ -5,6 +6,7 @@ using Elsa.Expressions.Models;
|
|||
using Elsa.Extensions;
|
||||
using Elsa.Workflows.Expressions;
|
||||
using Elsa.Workflows.Memory;
|
||||
using Elsa.Workflows.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Workflows.Management.Providers;
|
||||
|
|
@ -20,6 +22,7 @@ public class DefaultExpressionDescriptorProvider : IExpressionDescriptorProvider
|
|||
yield return CreateJsonDescriptor();
|
||||
yield return CreateDelegateDescriptor();
|
||||
yield return CreateVariableDescriptor();
|
||||
yield return CreateInputDescriptor();
|
||||
}
|
||||
|
||||
private ExpressionDescriptor CreateLiteralDescriptor()
|
||||
|
|
@ -72,6 +75,33 @@ public class DefaultExpressionDescriptorProvider : IExpressionDescriptorProvider
|
|||
);
|
||||
}
|
||||
|
||||
private ExpressionDescriptor CreateInputDescriptor()
|
||||
{
|
||||
return CreateDescriptor<InputExpressionHandler>(
|
||||
"Input",
|
||||
"Input", // Displayed text in UI (input selection dropdown)
|
||||
isBrowsable: true,
|
||||
deserialize: context =>
|
||||
{
|
||||
var valueElement = context.JsonElement.TryGetProperty("value", out var v) ? v : default;
|
||||
var valueString = valueElement.GetValue()?.ToString();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(valueString)) return new Expression("Input", null);
|
||||
|
||||
try
|
||||
{
|
||||
var value = JsonSerializer.Deserialize(valueString, typeof(InputDefinition), context.Options);
|
||||
|
||||
return new Expression("Input", value);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return new Expression("Input", null);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private static ExpressionDescriptor CreateDescriptor<THandler>(
|
||||
string expressionType,
|
||||
string displayName,
|
||||
|
|
|
|||
Loading…
Reference in a new issue