Skip to content

Commit

Permalink
Add 'From' methods and mark 'Get' methods as obsolete
Browse files Browse the repository at this point in the history
Added 'From' and 'From<T>' methods to the 'OutputProxy' class, which retrieve the value of a specified output from a certain activity. The pre-existing 'Get' methods, serving a similar function, have been marked as obsolete and updated to use the new 'From' methods.
  • Loading branch information
sfmskywalker committed Feb 14, 2024
1 parent eeb8aef commit 8b290ff
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/modules/Elsa.CSharp/Models/OutputProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,40 @@ public OutputProxy(ExpressionExecutionContext expressionExecutionContext)
{
_expressionExecutionContext = expressionExecutionContext;
}

/// <summary>
/// Gets the value of the specified output from the specified activity.
/// </summary>
/// <param name="activityIdOrName">The ID or name of the activity that produced the output.</param>
/// <param name="outputName">The name of the output.</param>
/// <returns>The value of the output.</returns>
public object? From(string activityIdOrName, string? outputName = default) => _expressionExecutionContext.GetOutput(activityIdOrName, outputName);

/// <summary>
/// Gets the value of the specified output from the specified activity.
/// </summary>
/// <param name="activityIdOrName">The ID or name of the activity that produced the output.</param>
/// <param name="outputName">The name of the output.</param>
/// <returns>The value of the output.</returns>
public T? From<T>(string activityIdOrName, string? outputName = default) => Get(activityIdOrName, outputName).ConvertTo<T>();

/// <summary>
/// Gets the value of the specified output.
/// </summary>
/// <param name="activityIdOrName">The ID or name of the activity that produced the output.</param>
/// <param name="outputName">The name of the output.</param>
/// <returns>The value of the output.</returns>
public object? Get(string activityIdOrName, string? outputName = default) => _expressionExecutionContext.GetOutput(activityIdOrName, outputName);
[Obsolete("Use From instead.")]
public object? Get(string activityIdOrName, string? outputName = default) => From(activityIdOrName, outputName);

/// <summary>
/// Gets the value of the specified output.
/// </summary>
/// <param name="activityIdOrName">The ID or name of the activity that produced the output.</param>
/// <param name="outputName">The name of the output.</param>
/// <returns>The value of the output.</returns>
public T? Get<T>(string activityIdOrName, string? outputName = default) => Get(activityIdOrName, outputName).ConvertTo<T>();
[Obsolete("Use From instead.")]
public T? Get<T>(string activityIdOrName, string? outputName = default) => From<T>(activityIdOrName, outputName);

/// <summary>
/// Gets the result of the last activity that executed.
Expand Down

0 comments on commit 8b290ff

Please sign in to comment.