parent
3ea596cdba
commit
cccf5c831d
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Attributes;
|
||||
|
|
@ -21,10 +22,14 @@ namespace Elsa.Activities.ControlFlow.Activities
|
|||
{
|
||||
private readonly IWorkflowExpressionEvaluator expressionEvaluator;
|
||||
|
||||
|
||||
public Switch(IWorkflowExpressionEvaluator expressionEvaluator)
|
||||
{
|
||||
this.expressionEvaluator = expressionEvaluator;
|
||||
Cases = new List<string>();
|
||||
Cases = new List<string>()
|
||||
{
|
||||
"default"
|
||||
};
|
||||
}
|
||||
|
||||
[ActivityProperty(Hint = "The expression to evaluate. The evaluated value will be used to switch on.")]
|
||||
|
|
@ -46,7 +51,15 @@ namespace Elsa.Activities.ControlFlow.Activities
|
|||
CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await expressionEvaluator.EvaluateAsync(Expression, workflowContext, cancellationToken);
|
||||
return Outcome(result);
|
||||
|
||||
if (Cases.Contains(result) || !Cases.Contains("default"))
|
||||
{
|
||||
return Outcome(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Outcome("default");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue