Lazy create ResourceInvoker.InvokeResultAsync statemachine

This commit is contained in:
Ben Adams 2019-04-12 03:01:44 +01:00 committed by Ryan Nowak
parent 305249709c
commit 8bb54fc22a
1 changed files with 21 additions and 11 deletions

View File

@ -247,12 +247,21 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
protected abstract Task InvokeInnerFilterAsync(); protected abstract Task InvokeInnerFilterAsync();
protected virtual async Task InvokeResultAsync(IActionResult result) protected virtual Task InvokeResultAsync(IActionResult result)
{ {
var actionContext = _actionContext; if (_diagnosticListener.IsEnabled() || _logger.IsEnabled(LogLevel.Trace))
{
return Logged(this, result);
}
_diagnosticListener.BeforeActionResult(actionContext, result); return result.ExecuteResultAsync(_actionContext);
_logger.BeforeExecutingActionResult(result);
static async Task Logged(ResourceInvoker invoker, IActionResult result)
{
var actionContext = invoker._actionContext;
invoker._diagnosticListener.BeforeActionResult(actionContext, result);
invoker._logger.BeforeExecutingActionResult(result);
try try
{ {
@ -260,8 +269,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
} }
finally finally
{ {
_diagnosticListener.AfterActionResult(actionContext, result); invoker._diagnosticListener.AfterActionResult(actionContext, result);
_logger.AfterExecutingActionResult(result); invoker._logger.AfterExecutingActionResult(result);
}
} }
} }