Skip to content

Commit

Permalink
Refactor ExpressionExecutionContextExtensions module
Browse files Browse the repository at this point in the history
Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity.
  • Loading branch information
sfmskywalker committed Dec 25, 2023
1 parent 2f10ef9 commit 3dc7ceb
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,37 +319,39 @@ public static IEnumerable<Variable> EnumerateVariablesInScope(this ExpressionExe
/// <summary>
/// Returns the value of the specified input.
/// </summary>
/// <param name="expressionExecutionContext"></param>
/// <param name="context"></param>
/// <param name="name">The name of the input.</param>
/// <typeparam name="T">The type of the input.</typeparam>
/// <returns>The value of the specified input.</returns>
public static T? GetInput<T>(this ExpressionExecutionContext expressionExecutionContext, string name)
public static T? GetInput<T>(this ExpressionExecutionContext context, string name)
{
var value = expressionExecutionContext.GetInput(name);
var value = context.GetInput(name);
return value.ConvertTo<T>();
}

/// <summary>
/// Returns the value of the specified input.
/// </summary>
/// <param name="expressionExecutionContext"></param>
/// <param name="context"></param>
/// <param name="name">The name of the input.</param>
/// <returns>The value of the specified input.</returns>
public static object? GetInput(this ExpressionExecutionContext expressionExecutionContext, string name)
public static object? GetInput(this ExpressionExecutionContext context, string name)
{
// If there's a variable in the current scope with the specified name, return that.
var variable = expressionExecutionContext.GetVariable(name);
if (context.IsInsideCompositeActivity())
{
// If there's a variable in the current scope with the specified name, return that.
var variable = context.GetVariable(name);

if (variable != null)
return variable.Get(expressionExecutionContext);
if (variable != null)
return variable.Get(context);
}

// Otherwise, return the input.
var workflowExecutionContext = expressionExecutionContext.GetWorkflowExecutionContext();
var workflowExecutionContext = context.GetWorkflowExecutionContext();
var input = workflowExecutionContext.Input;
return input.TryGetValue(name, out var value) ? value : default;
}



/// <summary>
/// Returns the value of the specified input.
/// </summary>
Expand Down

0 comments on commit 3dc7ceb

Please sign in to comment.