public object HandleFastCall(IAopProxy target, object executionTarget, int methodIndex, object[] rawParameters, Type returnType)
        {
            CallInfo info = MethodCache.GetCallInfo(methodIndex);

            MethodBase method = info.Method;
            IList interceptors = info.Interceptors;

            InterceptedParameter[] parameters = new InterceptedParameter[rawParameters.Length];
            int index = 0;
            foreach (InvocationParameterInfo parameterInfo in info.InvocationParameterInfos)
            {
                InterceptedParameter parameter = new InterceptedParameter(parameterInfo, rawParameters, index);
                parameters[index] = parameter;
                index++;
            }

            #if NET2
            MethodInvocation invocation = new MethodInvocation(target, executionTarget, method, method, parameters,rawParameters, returnType, interceptors);
            invocation.Handler = info.Handler;
            #else
            MethodInfo wrapperMethod = (MethodInfo) MethodCache.wrapperMethodLookup[info.MethodId];
            MethodInvocation invocation = new MethodInvocation(target, executionTarget, method, wrapperMethod , parameters,rawParameters, returnType, interceptors);
            #endif

            return invocation.Proceed();
        }
Exemple #2
0
        public object HandleFastCall(IAopProxy target, object executionTarget, int methodIndex, object[] rawParameters, Type returnType)
        {
            CallInfo info = MethodCache.GetCallInfo(methodIndex);

            MethodBase method       = info.Method;
            IList      interceptors = info.Interceptors;

            InterceptedParameter[] parameters = new InterceptedParameter[rawParameters.Length];
            int index = 0;

            foreach (InvocationParameterInfo parameterInfo in info.InvocationParameterInfos)
            {
                InterceptedParameter parameter = new InterceptedParameter(parameterInfo, rawParameters, index);
                parameters[index] = parameter;
                index++;
            }

#if NET2
            MethodInvocation invocation = new MethodInvocation(target, executionTarget, method, method, parameters, rawParameters, returnType, interceptors);
            invocation.Handler = info.Handler;
#else
            MethodInfo       wrapperMethod = (MethodInfo)MethodCache.wrapperMethodLookup[info.MethodId];
            MethodInvocation invocation    = new MethodInvocation(target, executionTarget, method, wrapperMethod, parameters, rawParameters, returnType, interceptors);
#endif

            return(invocation.Proceed());
        }
Exemple #3
0
        /// <summary>
        /// Initialization method.
        /// </summary>
        /// <param name="advised">The proxy configuration.</param>
        /// <param name="proxy">
        /// The current <see cref="Spring.Aop.Framework.IAopProxy"/> implementation.
        /// </param>
        protected void Initialize(IAdvised advised, IAopProxy proxy)
        {
            this.m_advised    = advised;
            this.m_targetType = advised.TargetSource.TargetType;

            // initialize target
            if (advised.TargetSource.IsStatic)
            {
                this.m_targetSourceWrapper = new StaticTargetSourceWrapper(advised.TargetSource);
            }
            else
            {
                this.m_targetSourceWrapper = new DynamicTargetSourceWrapper(advised.TargetSource);
            }

            // initialize introduction advice
            this.m_introductions = new IAdvice[advised.Introductions.Length];
            for (int i = 0; i < advised.Introductions.Length; i++)
            {
                this.m_introductions[i] = advised.Introductions[i].Advice;

                // set target proxy on introduction instance if it implements ITargetAware
                if (this.m_introductions[i] is ITargetAware)
                {
                    ((ITargetAware)this.m_introductions[i]).TargetProxy = proxy;
                }
            }
        }
Exemple #4
0
        public override MarshalByRefObject CreateInstance(Type serverType)
        {
            MarshalByRefObject target = base.CreateInstance(serverType);
            IAopProxy          proxy  = Factory.CreateProxyInstance(target, serverType);

            proxy.IsProxy = _proxy;
            return(proxy.ProxyObject);
        }
        public void SetProxy(IAopProxy target)
        {
            Shape2D shape = target as Shape2D;

            if (shape == null)
                throw new ArgumentException("target is not an IShape2D");

            this.shape = shape;
        }
Exemple #6
0
        public void TargetImplementsAnInterface()
        {
            ProxyFactory advisedSupport = new ProxyFactory(new TestObject());
            IAopProxy    aopProxy       = CreateAopProxy(advisedSupport);

            Assert.IsNotNull(aopProxy);

            Assert.IsTrue(AopUtils.IsCompositionAopProxy(aopProxy));
        }
Exemple #7
0
        public void SetProxy(IAopProxy target)
        {
            Shape2D shape = target as Shape2D;

            if (shape == null)
            {
                throw new ArgumentException("target is not an IShape2D");
            }

            this.shape = shape;
        }
        public void CannotProxyNonPublicClass()
        {
            NonPublicTestObject target = new NonPublicTestObject();

            mockTargetSource.SetTarget(target);
            AdvisedSupport advised = new AdvisedSupport(new Type[] { });

            advised.TargetSource = mockTargetSource;

            IAopProxy aop = CreateAopProxy(advised);
        }
Exemple #9
0
        public void TargetImplementsAnInterfaceWithProxyTargetTypeSetToTrue()
        {
            ProxyFactory advisedSupport = new ProxyFactory();

            advisedSupport.ProxyTargetType = true;
            advisedSupport.Target          = new TestObject();

            IAopProxy aopProxy = CreateAopProxy(advisedSupport);

            Assert.IsNotNull(aopProxy);
            Assert.IsTrue(AopUtils.IsDecoratorAopProxy(aopProxy));
        }
Exemple #10
0
 public MethodInvocation(IAopProxy target, object executionTarget, MethodBase method, MethodBase endMethod,
                         IList parameters,
                         Type returnType, IList interceptors)
 {
     Target          = target;
     ExecutionTarget = executionTarget;
     Method          = method;
     EndMethod       = endMethod;
     Parameters      = parameters;
     ReturnType      = returnType;
     Interceptors    = interceptors;
 }
Exemple #11
0
        public void TargetDoesNotImplementAnyInterfaces()
        {
            ProxyFactory advisedSupport = new ProxyFactory();

            advisedSupport.AopProxyFactory = new DefaultAopProxyFactory();
            advisedSupport.ProxyTargetType = false;
            advisedSupport.Target          = new DoesNotImplementAnyInterfacesTestObject();

            IAopProxy aopProxy = CreateAopProxy(advisedSupport);

            Assert.IsNotNull(aopProxy);
            Assert.IsTrue(AopUtils.IsDecoratorAopProxy(aopProxy));
        }
        public void SetProxy(IAopProxy target)
        {
            Shape shape = target as Shape;

            if (shape == null)
                throw new ArgumentException("target is not an IShape");

            this.shape = shape;

            DesignableAttribute attrib = (DesignableAttribute)shape.GetType().GetCustomAttributes(typeof(DesignableAttribute), true)[0];
            this.FillColor = attrib.FillColor;
            this.BorderColor = attrib.BorderColor;
            this.BorderSize = attrib.BorderSize;
        }
        public void SetProxy(IAopProxy target)
        {
            Shape2D shape = target as Shape2D;

            if (shape == null)
                throw new ArgumentException("target is not an IShape2D");

            this.shape = shape;
            this.selectable = (ISelectable)shape;

            IMouseHandler mouseShape = (IMouseHandler)shape;
            mouseShape.MouseDownHandlers.Add(MouseDown);
            mouseShape.MouseUpHandlers.Add(MouseUp);
            mouseShape.MouseMoveHandlers.Add(MouseMove);
        }
Exemple #14
0
        public void SetProxy(IAopProxy target)
        {
            Shape shape = target as Shape;

            if (shape == null)
            {
                throw new ArgumentException("target is not an IShape");
            }

            this.shape = shape;

            DesignableAttribute attrib = (DesignableAttribute)shape.GetType().GetCustomAttributes(typeof(DesignableAttribute), true)[0];

            this.FillColor   = attrib.FillColor;
            this.BorderColor = attrib.BorderColor;
            this.BorderSize  = attrib.BorderSize;
        }
        public object HandleFastCall(IAopProxy target, object executionTarget, int methodIndex, IList parameters, Type returnType)
        {
            CallInfo info = MethodCache.GetCallInfo(methodIndex);

            MethodBase method       = info.Method;
            IList      interceptors = info.Interceptors;


#if NET2
            MethodInvocation invocation = new MethodInvocation(target, executionTarget, method, method, parameters, returnType, interceptors);
            invocation.Handler = info.Handler;
#else
            MethodInfo       wrapperMethod = (MethodInfo)MethodCache.wrapperMethodLookup[info.MethodId];
            MethodInvocation invocation    = new MethodInvocation(target, executionTarget, method, wrapperMethod, parameters, returnType, interceptors);
#endif

            return(invocation.Proceed());
        }
Exemple #16
0
        public void SetProxy(IAopProxy target)
        {
            Shape2D shape = target as Shape2D;

            if (shape == null)
            {
                throw new ArgumentException("target is not an IShape2D");
            }

            this.shape      = shape;
            this.selectable = (ISelectable)shape;

            IMouseHandler mouseShape = (IMouseHandler)shape;

            mouseShape.MouseDownHandlers.Add(MouseDown);
            mouseShape.MouseUpHandlers.Add(MouseUp);
            mouseShape.MouseMoveHandlers.Add(MouseMove);
        }
        public object HandleFastCall(IAopProxy target, object executionTarget, int methodIndex, IList parameters, Type returnType)
        {
            CallInfo info = MethodCache.GetCallInfo(methodIndex);

            MethodBase method = info.Method;
            IList interceptors = info.Interceptors;

            
#if NET2
			MethodInvocation invocation = new MethodInvocation(target, executionTarget, method, method , parameters, returnType, interceptors);
			invocation.Handler = info.Handler;
#else            
			MethodInfo wrapperMethod = (MethodInfo) MethodCache.wrapperMethodLookup[info.MethodId];
			MethodInvocation invocation = new MethodInvocation(target, executionTarget, method, wrapperMethod , parameters, returnType, interceptors);
#endif
            
            return invocation.Proceed();
        }
Exemple #18
0
        /// <summary>
        /// Initialization method.
        /// </summary>
        /// <param name="advised">The proxy configuration.</param>
        /// <param name="proxy">
        /// The current <see cref="Spring.Aop.Framework.IAopProxy"/> implementation.
        /// </param>
        protected void Initialize(IAdvised advised, IAopProxy proxy)
        {
            this.m_advised      = advised;
            this.m_targetSource = advised.TargetSource;
            this.m_targetType   = advised.TargetSource.TargetType;

            // initialize introduction advice
            this.m_introductions = new IAdvice[advised.Introductions.Count];
            for (int i = 0; i < advised.Introductions.Count; i++)
            {
                this.m_introductions[i] = advised.Introductions[i].Advice;

                // set target proxy on introduction instance if it implements ITargetAware
                if (this.m_introductions[i] is ITargetAware)
                {
                    ((ITargetAware)this.m_introductions[i]).TargetProxy = proxy;
                }
            }
        }
Exemple #19
0
        public void SetProxy(IAopProxy target)
        {
            Shape2D shape = target as Shape2D;

            if (shape == null)
            {
                throw new ArgumentException("target is not an IShape2D");
            }

            this.shape = shape;

            ResizableAttribute attrib = (ResizableAttribute)shape.GetType().GetCustomAttributes(typeof(ResizableAttribute), true)[0];

            KeepProportions = attrib.KeepProportions;

            IMouseHandler mouseShape = (IMouseHandler)shape;

            mouseShape.MouseDownHandlers.Add(MouseDown);
            mouseShape.MouseUpHandlers.Add(MouseUp);
            mouseShape.MouseMoveHandlers.Add(MouseMove);
        }
        public void DoesNotProxyTargetVirtualMethodReturnValueAttributesWithProxyTargetAttributesEqualsFalse()
        {
            MarkerClass target = new MarkerClass();

            AdvisedSupport advised = new AdvisedSupport(new Type[] { typeof(IMarkerInterface) });

            advised.Target = target;
            advised.ProxyTargetAttributes = false;
            IAopProxy aopProxy = CreateAopProxy(advised);

            object proxy = aopProxy.GetProxy();

            Assert.IsNotNull(proxy, "The proxy generated by a (valid) call to GetProxy() was null.");

            MethodInfo method = proxy.GetType().GetMethod("MarkerVirtualMethod");

            Assert.IsNotNull(method);

            object[] attrs = method.ReturnTypeCustomAttributes.GetCustomAttributes(false);
            Assert.IsNotNull(attrs);
            Assert.AreEqual(0, attrs.Length, "Should not have attribute applied to the method's return value.");
        }
        public void ProxyTargetVirtualMethodParameterAttributes()
        {
            MarkerClass target = new MarkerClass();

            AdvisedSupport advised = new AdvisedSupport(new Type[] { typeof(IMarkerInterface) });

            advised.Target = target;
            IAopProxy aopProxy = CreateAopProxy(advised);

            object proxy = aopProxy.GetProxy();

            Assert.IsNotNull(proxy, "The proxy generated by a (valid) call to GetProxy() was null.");

            MethodInfo method = proxy.GetType().GetMethod("MarkerVirtualMethod");

            Assert.IsNotNull(method);

            object[] attrs = method.GetParameters()[1].GetCustomAttributes(false);
            Assert.IsNotNull(attrs, "Should have had 1 attribute applied to the method's parameter.");
            Assert.AreEqual(1, attrs.Length, "Should have had 1 attribute applied to the method's parameter.");
            Assert.AreEqual(typeof(MarkerAttribute), attrs[0].GetType(), "Wrong System.Type of Attribute applied to the method's parameter.");
        }
        public void ProxyCanBeClassAndInterface()
        {
            TestObject target = new TestObject();

            target.Age = 32;
            mockTargetSource.SetTarget(target);
            AdvisedSupport advised = new AdvisedSupport();

            advised.TargetSource = mockTargetSource;
            IAopProxy aop = CreateAopProxy(advised);

            object proxy = aop.GetProxy();

            Assert.IsTrue(AopUtils.IsDecoratorAopProxy(proxy), "Should be a decorator-based proxy");
            Assert.IsTrue(proxy is ITestObject);
            Assert.IsTrue(proxy is TestObject);

            ITestObject itb = (ITestObject)proxy;

            Assert.AreEqual(32, itb.Age, "Incorrect age");
            TestObject tb = (TestObject)proxy;

            Assert.AreEqual(32, tb.Age, "Incorrect age");
        }
 public void SetProxy(Puzzle.NAspect.Framework.IAopProxy target)
 {
     this.target = target;
 }
        public void SetProxy(IAopProxy target)
        {
            Shape2D shape = target as Shape2D;

            if (shape == null)
                throw new ArgumentException("target is not an IShape2D");

            this.shape = shape;

            ResizableAttribute attrib = (ResizableAttribute)shape.GetType().GetCustomAttributes(typeof(ResizableAttribute), true)[0];

            KeepProportions = attrib.KeepProportions;

            IMouseHandler mouseShape = (IMouseHandler)shape;
            mouseShape.MouseDownHandlers.Add(MouseDown);
            mouseShape.MouseUpHandlers.Add(MouseUp);
            mouseShape.MouseMoveHandlers.Add(MouseMove);
        }
 /// <summary>
 /// Assigns a proxy instance to the mixin.
 /// </summary>
 /// <param name="target"></param>
 public void SetProxy(IAopProxy target)
 {
 }
Exemple #26
0
 public void SetProxy(IAopProxy target)
 {
     this.target = (IPersistentObject)target;
 }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Aop.Framework.DynamicProxy.AdvisedProxy"/> class.
 /// </summary>
 /// <param name="advised">The proxy configuration.</param>
 /// <param name="proxy">The proxy.</param>
 public AdvisedProxy(IAdvised advised, IAopProxy proxy)
 {
     Initialize(advised, proxy);
 }
		//called when ctor of target is intercepted
		public void SetProxy(IAopProxy target)
		{
			targetList = (IList)target;
			interceptor.List = targetList;
		}
        /// <summary>
        /// Initialization method.
        /// </summary>
        /// <param name="advised">The proxy configuration.</param>
        /// <param name="proxy">
        /// The current <see cref="Spring.Aop.Framework.IAopProxy"/> implementation.
        /// </param>
        protected void Initialize(IAdvised advised, IAopProxy proxy)
        {
            this.m_advised = advised;
            this.m_targetType = advised.TargetSource.TargetType;

            // initialize target
            if (advised.TargetSource.IsStatic)
            {
                this.m_targetSourceWrapper = new StaticTargetSourceWrapper(advised.TargetSource);
            }
            else
            {
                this.m_targetSourceWrapper = new DynamicTargetSourceWrapper(advised.TargetSource);
            }

            // initialize introduction advice
            this.m_introductions = new IAdvice[advised.Introductions.Length];
            for (int i = 0; i < advised.Introductions.Length; i++)
            {
                this.m_introductions[i] = advised.Introductions[i].Advice;

                // set target proxy on introduction instance if it implements ITargetAware
                if (this.m_introductions[i] is ITargetAware)
                {
                    ((ITargetAware)this.m_introductions[i]).TargetProxy = proxy;
                }
            }
        }
 public void SetProxy(IAopProxy target)
 {
     this.target = (IPersistentObject)target;
 }
        /// <summary>
        /// Creates a new proxy according to the settings in this factory.
        /// </summary>
        /// <remarks>
        /// <p>
        /// Can be called repeatedly; the effect of repeated invocations will
        /// (of course) vary if interfaces have been added or removed.
        /// </p>
        /// </remarks>
        /// <returns>An AOP proxy for target object.</returns>
        public virtual object GetProxy()
        {
            IAopProxy proxy = CreateAopProxy();

            return(proxy.GetProxy());
        }
 public void SetProxy(IAopProxy target)
 {
 //    this.target = target;
 }
 public void SetProxy(Puzzle.NAspect.Framework.IAopProxy target)
 {
     this.target = target;
 }
 public void SetProxy(IAopProxy target)
 {
     proxy = target;
 }
Exemple #35
0
 public void SetProxy(IAopProxy target)
 {
     proxy = target;
 }
Exemple #36
0
 /// <summary>
 /// Assigns a proxy instance to the mixin.
 /// </summary>
 /// <param name="target"></param>
 public void SetProxy(IAopProxy target)
 {
 }
Exemple #37
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Aop.Framework.DynamicProxy.AdvisedProxy"/> class.
 /// </summary>
 /// <param name="advised">The proxy configuration.</param>
 /// <param name="proxy">The proxy.</param>
 public AdvisedProxy(IAdvised advised, IAopProxy proxy)
 {
     Initialize(advised, proxy);
 }
        /// <summary>
        /// Initialization method.
        /// </summary>
        /// <param name="advised">The proxy configuration.</param>
        /// <param name="proxy">
        /// The current <see cref="Spring.Aop.Framework.IAopProxy"/> implementation.
        /// </param>
        protected void Initialize(IAdvised advised, IAopProxy proxy)
        {
            this.m_advised = advised;
            this.m_targetSource = advised.TargetSource;
            this.m_targetType = advised.TargetSource.TargetType;

            // initialize introduction advice
            this.m_introductions = new IAdvice[advised.Introductions.Count];
            for (int i = 0; i < advised.Introductions.Count; i++)
            {
                this.m_introductions[i] = advised.Introductions[i].Advice;

                // set target proxy on introduction instance if it implements ITargetAware
                if (this.m_introductions[i] is ITargetAware)
                {
                    ((ITargetAware)this.m_introductions[i]).TargetProxy = proxy;
                }
            }
        }
Exemple #39
0
 public void SetProxy(IAopProxy target)
 {
     this.target = target;
 }
Exemple #40
0
 //called when ctor of target is intercepted
 public void SetProxy(IAopProxy target)
 {
     targetList       = (IList)target;
     interceptor.List = targetList;
 }