public static object Intercept(MemberInfo member, MethodInfo callerMethod, object target, object[] parameters, Type interceptorProviderType, params IInterceptor[] interceptors)
        {
            if (member is null)
            {
                throw new ArgumentNullException(nameof(member));
            }
            if (callerMethod is null)
            {
                throw new ArgumentNullException(nameof(callerMethod));
            }
            if (interceptorProviderType is null)
            {
                throw new ArgumentNullException(nameof(interceptorProviderType));
            }

            try
            {
                var invocation = new ReflectionInvocation(target, interceptors, member, callerMethod, interceptorProviderType, parameters);
                invocation.Proceed();
                return(invocation.ReturnValue);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
            public void Proceed()
            {
                int invocationInterceptorIndex = invocation.currentInterceptorIndex;

                try
                {
                    invocation.currentInterceptorIndex = originalInterceptorIndex;
                    invocation.Proceed();
                }
                finally
                {
                    invocation.currentInterceptorIndex = invocationInterceptorIndex;
                }
            }