public override async Task Intercept(IInvocationAsync invocation) { // do some async work before proceed await Task.Yield(); await invocation.Proceed(); }
public override async Task Intercept(IInvocationAsync invocation) { try { LogInterceptStart(invocation); await _delays.BeforeProceed().ConfigureAwait(false); await invocation.Proceed().ConfigureAwait(false); await _delays.AfterProceed().ConfigureAwait(false); await LogReturnValue((dynamic)invocation.ReturnValue, invocation).ConfigureAwait(false); LogInterceptEnd(invocation); } catch (Exception ex) { _log.Add($"{invocation.Method.Name}:InterceptException:{ex.Message}"); throw; } finally { _log.Freeze(); } }
public override async Task Intercept(IInvocationAsync invocation) { // do some work before invocation await Task.Yield(); // invoke await invocation.Proceed(); // override the return value invocation.ReturnValue = (int)invocation.Arguments[0] + 1; }
/// <summary> /// Intercepts a asynchronous method <paramref name="invocation"/>. /// </summary> /// <param name="invocation">The method invocation.</param> public virtual Task Intercept(IInvocationAsync invocation) { return(invocation.Proceed()); }