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.
|
|
|
|
namespace Connected.Services.Middleware
|
|
|
|
|
{
|
|
|
|
|
public abstract class FunctionMiddleware<TArgs, TReturnValue> : ServiceMiddleware<TArgs>, IFunctionMiddleware<TArgs, TReturnValue>
|
|
|
|
|
{
|
|
|
|
|
protected TArgs? Arguments { get; private set; }
|
|
|
|
|
public async Task<TReturnValue?> Invoke(TArgs? args, TReturnValue? result)
|
|
|
|
|
{
|
|
|
|
|
Arguments = args;
|
|
|
|
|
|
|
|
|
|
await OnValidate();
|
|
|
|
|
return await OnInvoke(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual async Task<TReturnValue?> OnInvoke(TReturnValue? result)
|
|
|
|
|
{
|
|
|
|
|
await Task.CompletedTask;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual async Task OnValidate()
|
|
|
|
|
{
|
|
|
|
|
await Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|