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