Example #1
0
 public Invocation(
     object target,
     IProxy proxy,
     MethodInfo method, 
     object[] arguments,
     ProxyTargetInvocation proxyTargetInvocation,
     IInterceptor[] interceptors)
 {
     _target = target;
     _proxy = proxy;
     _method = method;
     _arguments = arguments;
     _proxyTargetInvocation = proxyTargetInvocation;
     _interceptors = interceptors;
 }
        public object MethodInvocation(
            object target,
            MethodInfo method, 
            object[] arguments, 
            ProxyTargetInvocation proxyTargetInvocation)
        {
            if (_interceptors.Length == 0)
            {
                return proxyTargetInvocation(arguments);
            }

            var invocation = new Invocation(
                target,
                (IProxy)target, // TODO: Fix
                method,
                arguments,
                proxyTargetInvocation,
                _interceptors);

            invocation.ExecuteInterceptors();

            return invocation.ReturnValue;
        }