using Elsa.Expressions.Helpers;
using Elsa.Expressions.Models;
using Elsa.Extensions;
using JetBrains.Annotations;
namespace Elsa.Python.Models;
///
/// Provides access to the current execution context.
///
[UsedImplicitly]
public partial class ExecutionContextProxy
{
///
/// Gets the current execution context.
///
public ExpressionExecutionContext ExpressionExecutionContext { get; }
///
/// Initializes a new instance of the class.
///
public ExecutionContextProxy(ExpressionExecutionContext expressionExecutionContext)
{
ExpressionExecutionContext = expressionExecutionContext;
}
///
/// Gets the value of the specified variable.
///
public object? GetVariable(string name) => ExpressionExecutionContext.GetVariableInScope(name).ConvertTo();
///
/// Sets the value of the specified variable.
///
public void SetVariable(string name, object? value) => ExpressionExecutionContext.SetVariable(name, value);
///
/// Gets the workflow instance ID.
///
public string WorkflowInstanceId => ExpressionExecutionContext.GetWorkflowExecutionContext().Id;
///
/// Gets or sets the correlation ID.
///
public string? CorrelationId
{
get => ExpressionExecutionContext.GetWorkflowExecutionContext().CorrelationId;
set => ExpressionExecutionContext.GetWorkflowExecutionContext().CorrelationId = value;
}
}