2023-11-03 23:23:37 +00:00
|
|
|
using Elsa.Expressions.Helpers;
|
|
|
|
|
using Elsa.Expressions.Models;
|
|
|
|
|
using Elsa.Extensions;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
|
|
|
|
namespace Elsa.Python.Models;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides access to the current execution context.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
public partial class ExecutionContextProxy
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the current execution context.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ExpressionExecutionContext ExpressionExecutionContext { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="ExecutionContextProxy"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ExecutionContextProxy(ExpressionExecutionContext expressionExecutionContext)
|
|
|
|
|
{
|
|
|
|
|
ExpressionExecutionContext = expressionExecutionContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the value of the specified variable.
|
|
|
|
|
/// </summary>
|
2023-11-19 20:13:19 +00:00
|
|
|
public object? GetVariable<T>(string name) => ExpressionExecutionContext.GetVariableInScope(name).ConvertTo<T>();
|
2023-12-28 13:18:07 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the value of the specified variable.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public object? GetVariable(string name) => ExpressionExecutionContext.GetVariableInScope(name);
|
2023-11-03 23:23:37 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the value of the specified variable.
|
|
|
|
|
/// </summary>
|
2023-11-19 20:13:19 +00:00
|
|
|
public void SetVariable(string name, object? value) => ExpressionExecutionContext.SetVariable(name, value);
|
2023-11-04 17:38:11 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the workflow instance ID.
|
|
|
|
|
/// </summary>
|
2023-11-19 20:13:19 +00:00
|
|
|
public string WorkflowInstanceId => ExpressionExecutionContext.GetWorkflowExecutionContext().Id;
|
2023-11-04 17:38:11 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the correlation ID.
|
|
|
|
|
/// </summary>
|
2023-11-19 20:13:19 +00:00
|
|
|
public string? CorrelationId
|
2023-11-04 17:38:11 +00:00
|
|
|
{
|
|
|
|
|
get => ExpressionExecutionContext.GetWorkflowExecutionContext().CorrelationId;
|
|
|
|
|
set => ExpressionExecutionContext.GetWorkflowExecutionContext().CorrelationId = value;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-03 23:23:37 +00:00
|
|
|
}
|