Add WorkflowInstanceName property to Globals

Introduces a new property, `WorkflowInstanceName`, to access and modify the name of the current workflow instance. Also simplifies object initialization by using target-typed new expressions. Annotates the `Globals` class with `[UsedImplicitly]` to improve code analysis.
This commit is contained in:
Sipke Schoorstra 2025-03-02 11:24:21 +01:00
parent 549b4709d0
commit 27fe72d123
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F

View file

@ -1,11 +1,13 @@
using Elsa.Expressions.Models;
using Elsa.Extensions;
using JetBrains.Annotations;
namespace Elsa.CSharp.Models;
/// <summary>
/// Provides access to global objects, such as the workflow execution context.
/// </summary>
[UsedImplicitly]
public partial class Globals
{
/// <summary>
@ -15,9 +17,9 @@ public partial class Globals
{
ExpressionExecutionContext = expressionExecutionContext;
Arguments = arguments;
ExecutionContext = new ExecutionContextProxy(expressionExecutionContext);
Output = new OutputProxy(expressionExecutionContext);
Outcome = new OutcomeProxy(expressionExecutionContext);
ExecutionContext = new(expressionExecutionContext);
Output = new(expressionExecutionContext);
Outcome = new(expressionExecutionContext);
}
/// <summary>
@ -48,6 +50,15 @@ public partial class Globals
get => ExpressionExecutionContext.GetWorkflowExecutionContext().CorrelationId;
set => ExpressionExecutionContext.GetWorkflowExecutionContext().CorrelationId = value;
}
/// <summary>
/// Gets or sets the name of the current workflow instance.
/// </summary>
public string? WorkflowInstanceName
{
get => ExpressionExecutionContext.GetWorkflowExecutionContext().Name;
set => ExpressionExecutionContext.GetWorkflowExecutionContext().Name = value;
}
/// <summary>
/// Gets additional arguments provided by the caller of the evaluator.