Make CurrentScope nullable

This commit is contained in:
Sipke Schoorstra 2021-05-05 13:12:11 +02:00
parent 441ae741cd
commit dd772a3c74
4 changed files with 5 additions and 5 deletions

View file

@ -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);

View file

@ -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)

View file

@ -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));
}

View file

@ -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));