You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Services/NullableServiceFunction.cs

25 lines
554 B

2 years ago
namespace Connected.Services;
public abstract class NullableServiceFunction<TArgs, TReturnValue> : ServiceOperation<TArgs>, INullableFunction<TArgs, TReturnValue>
where TArgs : IDto
{
protected TReturnValue? Result { get; private set; }
public async Task<TReturnValue?> Invoke(TArgs args)
{
if (args is null)
throw new ArgumentException(null, nameof(args));
Arguments = args;
Result = await OnInvoke();
return Result;
}
protected virtual async Task<TReturnValue?> OnInvoke()
{
await Task.CompletedTask;
return default;
}
}