Make CurrentScope nullable
This commit is contained in:
parent
441ae741cd
commit
dd772a3c74
|
|
@ -107,7 +107,7 @@ namespace Elsa.Services.Models
|
|||
set => WorkflowExecutionContext.WorkflowInstance.ActivityOutput.SetItem(ActivityBlueprint.Id, value);
|
||||
}
|
||||
|
||||
public ActivityScope CurrentScope => WorkflowExecutionContext.CurrentScope;
|
||||
public ActivityScope? CurrentScope => WorkflowExecutionContext.CurrentScope;
|
||||
public ActivityScope GetScope(string activityId) => WorkflowExecutionContext.GetScope(activityId);
|
||||
public ActivityScope GetNamedScope(string activityName) => WorkflowExecutionContext.GetNamedScope(activityName);
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ namespace Elsa.Services.Models
|
|||
public void PurgeVariables() => WorkflowInstance.Variables.RemoveAll();
|
||||
|
||||
|
||||
public ActivityScope CurrentScope => WorkflowInstance.Scopes.Peek();
|
||||
public ActivityScope? CurrentScope => WorkflowInstance.Scopes.Any() ? WorkflowInstance.Scopes.Peek() : default;
|
||||
public ActivityScope GetScope(string activityId) => WorkflowInstance.Scopes.First(x => x.ActivityId == activityId);
|
||||
|
||||
public ActivityScope GetNamedScope(string activityName)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Elsa.Activities.ControlFlow
|
|||
|
||||
public static class ForActivityScopeExtensions
|
||||
{
|
||||
public static ForScope ForScope(this ActivityExecutionContext context) => new(context.CurrentScope);
|
||||
public static ForScope ForScope(this ActivityExecutionContext context) => new(context.CurrentScope!);
|
||||
public static ForScope ForScope(this ActivityExecutionContext context, string activityId) => new(context.GetScope(activityId));
|
||||
public static ForScope ForNamedScope(this ActivityExecutionContext context, string activityId) => new(context.GetNamedScope(activityId));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ namespace Elsa.Activities.ControlFlow
|
|||
|
||||
public static class ForEachActivityScopeExtensions
|
||||
{
|
||||
public static ForEachScope ForEachScope(this ActivityExecutionContext context) => new(context.CurrentScope);
|
||||
public static ForEachScope ForEachScope(this ActivityExecutionContext context) => new(context.CurrentScope!);
|
||||
public static ForEachScope ForEachScope(this ActivityExecutionContext context, string activityId) => new(context.GetScope(activityId));
|
||||
public static ForEachScope ForEachNamedScope(this ActivityExecutionContext context, string activityName) => new(context.GetNamedScope(activityName));
|
||||
public static ForEachScope<T> ForEachScope<T>(this ActivityExecutionContext context) => new(context.CurrentScope);
|
||||
public static ForEachScope<T> ForEachScope<T>(this ActivityExecutionContext context) => new(context.CurrentScope!);
|
||||
public static ForEachScope<T> ForEachScope<T>(this ActivityExecutionContext context, string activityId) => new(context.GetScope(activityId));
|
||||
public static ForEachScope<T> ForEachNamedScope<T>(this ActivityExecutionContext context, string activityName) => new(context.GetNamedScope(activityName));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue