Exemplo n.º 1
0
        public Task <object?> EvaluateAsync(string expression, Type returnType, ActivityExecutionContext context, CancellationToken cancellationToken)
        {
            var matches = rx.Matches(expression);

            foreach (Match match in matches)
            {
                var variable = match.Groups[1].Value;

                string replacement = match.Groups[0].Value;

                switch (variable)
                {
                case "correlationId":
                    replacement = $"'{context.WorkflowExecutionContext.CorrelationId}'";
                    break;

                case "workflowDefinitionId":
                    replacement = $"'{context.WorkflowInstance.DefinitionId}'";
                    break;

                case "workflowDefinitionVersion":
                    replacement = $"{context.WorkflowInstance.DefinitionVersionId}";
                    break;

                case "workflowInstanceId":
                    replacement = $"'{context.WorkflowInstance.Id}'";
                    break;

                default:
                    if (context.HasVariable(variable))
                    {
                        var value = context.GetVariable(variable);
                        if (value is not null)
                        {
                            replacement = IsNumber(value)? $"{value}" : $"'{value}'";
                        }
                        else
                        {
                            replacement = "NULL";
                        }
                    }
                    break;
                }

                expression = expression.Replace(match.Groups[0].Value, replacement);
            }

            return(Task.FromResult(expression.Parse(returnType)));
        }
Exemplo n.º 2
0
 public static bool HasFromNumber(this ActivityExecutionContext context) => context.HasVariable(FromNumberVariableName);
Exemplo n.º 3
0
 public static bool HasCallControlId(this ActivityExecutionContext context) => context.HasVariable(CallControlIdVariableName);