diff --git a/src/core/Elsa.Abstractions/Services/Models/ActivityExecutionContext.cs b/src/core/Elsa.Abstractions/Services/Models/ActivityExecutionContext.cs index 6260d07af..36520429f 100644 --- a/src/core/Elsa.Abstractions/Services/Models/ActivityExecutionContext.cs +++ b/src/core/Elsa.Abstractions/Services/Models/ActivityExecutionContext.cs @@ -84,10 +84,17 @@ namespace Elsa.Services.Models var activityTypeService = ServiceScope.ServiceProvider.GetRequiredService(); return await activityTypeService.ActivateActivityAsync(ActivityBlueprint, cancellationToken); } - + public T? GetInput() => Input.ConvertTo(); + public T? GetInput(Func defaultValue) => Input != null ? Input.ConvertTo() : defaultValue(); + public T? GetInput(T? defaultValue) => Input != null ? Input.ConvertTo() : defaultValue; + public object? GetOutputFrom(string activityName) => WorkflowExecutionContext.GetOutputFrom(activityName); - public T GetOutputFrom(string activityName) => (T) GetOutputFrom(activityName)!; + public object? GetOutputFrom(string activityName, object? defaultValue) => WorkflowExecutionContext.GetOutputFrom(activityName) ?? defaultValue; + public object? GetOutputFrom(string activityName, Func defaultValue) => WorkflowExecutionContext.GetOutputFrom(activityName) ?? defaultValue(); + public T? GetOutputFrom(string activityName) => (T?) GetOutputFrom(activityName)!; + public T? GetOutputFrom(string activityName, Func defaultValue) => (T?) GetOutputFrom(activityName, defaultValue())!; + public T? GetOutputFrom(string activityName, T? defaultValue) => (T?) GetOutputFrom(activityName, () => defaultValue)!; public void SetWorkflowContext(object? value) => WorkflowExecutionContext.SetWorkflowContext(value); public T GetWorkflowContext() => WorkflowExecutionContext.GetWorkflowContext(); }