Fix nullable warnings

This commit is contained in:
Sipke Schoorstra 2020-11-18 20:44:04 +01:00
parent 660adacf61
commit eba08c09de
2 changed files with 4 additions and 4 deletions

View file

@ -41,7 +41,7 @@ namespace Elsa.Services.Models
public object? GetVariable(string name) => WorkflowExecutionContext.GetVariable(name);
public T GetVariable<T>(string name) => WorkflowExecutionContext.GetVariable<T>(name);
public T GetVariable<T>() => GetVariable<T>(typeof(T).Name);
public T GetService<T>() => WorkflowExecutionContext.ServiceProvider.GetService<T>();
public T GetService<T>() where T : notnull => WorkflowExecutionContext.ServiceProvider.GetRequiredService<T>();
public async ValueTask<IActivity> ActivateActivityAsync(CancellationToken cancellationToken = default)
{
@ -66,9 +66,9 @@ namespace Elsa.Services.Models
return activity;
}
public T GetInput<T>() => (T)Input!;
public T GetInput<T>() => (T) Input!;
public object? GetOutputFrom(string activityName) => WorkflowExecutionContext.GetOutputFrom(activityName);
public T GetOutputFrom<T>(string activityName) => (T)GetOutputFrom(activityName)!;
public T GetOutputFrom<T>(string activityName) => (T) GetOutputFrom(activityName)!;
public void SetWorkflowContext(object? value) => WorkflowExecutionContext.SetWorkflowContext(value);
public T GetWorkflowContext<T>() => WorkflowExecutionContext.GetWorkflowContext<T>();
}

View file

@ -23,7 +23,7 @@ namespace Elsa.Triggers
return await workflowBlueprint.GetActivityPropertyValue(activityId, propertyExpression, _activityExecutionContext, cancellationToken);
}
public T GetState<T>(Expression<Func<TActivity, T>> propertyExpression)
public T? GetState<T>(Expression<Func<TActivity, T>> propertyExpression)
{
var workflowBlueprint = _activityExecutionContext.WorkflowExecutionContext.WorkflowBlueprint;
return workflowBlueprint.GetActivityState(propertyExpression, _activityExecutionContext);