Example #1
0
        public void Intercept(IInvocation invocation)
        {
            // find local instance from instanceMap
            MethodInfo          methodInfo         = invocation.Method;
            IGeneralInterceptor generalInterceptor = interceptorsMap.Find(methodInfo);

            if (generalInterceptor == null)
            {
                throw new MissingMethodException($"{methodInfo} was not implemented");
            }
            object value = methodInfo.GetDefaultReturnValue();

            generalInterceptor
            .Invoke(
                instanceMap,
                ref value,
                invocation.Arguments,
                invocation.GenericArguments,
                methodInfo);
            invocation.ReturnValue = value;
        }