public virtual void Intercept(IInvocation invocation)
        {
            MethodType methodType = GetMethodType(invocation.Method.ReturnType);

            switch (methodType)
            {
            case MethodType.AsyncAction:
                _asyncInterceptor.InterceptAsynchronous(invocation);
                return;

            case MethodType.AsyncFunction:
                GetHandler(invocation.Method.ReturnType).Invoke(invocation, _asyncInterceptor);
                return;

            default:
                _asyncInterceptor.InterceptSynchronous(invocation);
                return;
            }
        }
예제 #2
0
 /// <summary>
 /// This method is created as a delegate and used to make the call to the generic
 /// <see cref="IAsyncInterceptor.InterceptAsynchronous{T}"/> method.
 /// </summary>
 /// <typeparam name="TResult">The type of the <see cref="Task{T}"/> <see cref="Task{T}.Result"/> of the method
 /// <paramref name="invocation"/>.</typeparam>
 private static void HandleAsyncWithResult <TResult>(IInvocation invocation, IAsyncInterceptor asyncInterceptor)
 {
     asyncInterceptor.InterceptAsynchronous <TResult>(invocation);
 }