Intercept the call to an async method using DynamicProxy

后端 未结 8 1009
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 02:30

Below is the code from the Intercept method on a custom type that implements IInterceptor of the Castle Dynamic Proxy library. This snippet is from

8条回答
  •  隐瞒了意图╮
    2020-12-13 03:16

       void IInterceptor.Intercept(IInvocation invocation) {
           try {
               invocation.Proceed();
               var task = invocation.ReturnValue as Task;
               if (task != null && task.IsFaulted) throw task.Exception;
           }
           catch {
               throw;
           }
       }
    

提交回复
热议问题