public Task InvokeActionAsync(MethodInfo targetMethod, object[] args) { var interceptor = _interceptorFactory(targetMethod); if (interceptor is null) { return(_inner.InvokeActionAsync(targetMethod, args)); } return(WeavingInvoke()); async Task WeavingInvoke() { using ( interceptor ) { interceptor?.BeforeCall(args); try { await _inner.InvokeActionAsync(targetMethod, args); } catch (Exception e) { interceptor?.OnError(e); throw; } interceptor?.AfterCompletion(); } } }
public async Task InvokeActionAsync(MethodInfo targetMethod, object[] args) { var delays = _retryStrategy.Delays.GetEnumerator(); for (; ;) { try { await _inner.InvokeActionAsync(targetMethod, args); return; } catch (Exception e) when(WillRetry(e, delays)) { await Task.Delay(delays.Current); } } }