コード例 #1
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();
        }
コード例 #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());
        }
コード例 #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;
                }
            }
        }
コード例 #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);
        }
コード例 #5
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;
        }
コード例 #6
0
        public void TargetImplementsAnInterface()
        {
            ProxyFactory advisedSupport = new ProxyFactory(new TestObject());
            IAopProxy    aopProxy       = CreateAopProxy(advisedSupport);

            Assert.IsNotNull(aopProxy);

            Assert.IsTrue(AopUtils.IsCompositionAopProxy(aopProxy));
        }
コード例 #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;
        }
コード例 #8
0
        public void CannotProxyNonPublicClass()
        {
            NonPublicTestObject target = new NonPublicTestObject();

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

            advised.TargetSource = mockTargetSource;

            IAopProxy aop = CreateAopProxy(advised);
        }
コード例 #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));
        }
コード例 #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;
 }
コード例 #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));
        }
コード例 #12
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;
        }
コード例 #13
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);
        }
コード例 #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;
        }
コード例 #15
0
        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());
        }
コード例 #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);
        }
コード例 #17
0
        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();
        }
コード例 #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;
                }
            }
        }
コード例 #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);
        }
コード例 #20
0
        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.");
        }
コード例 #21
0
        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.");
        }
コード例 #22
0
        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");
        }
コード例 #23
0
 public void SetProxy(Puzzle.NAspect.Framework.IAopProxy target)
 {
     this.target = target;
 }
コード例 #24
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);
        }
コード例 #25
0
 /// <summary>
 /// Assigns a proxy instance to the mixin.
 /// </summary>
 /// <param name="target"></param>
 public void SetProxy(IAopProxy target)
 {
 }
コード例 #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);
 }
コード例 #28
0
		//called when ctor of target is intercepted
		public void SetProxy(IAopProxy target)
		{
			targetList = (IList)target;
			interceptor.List = targetList;
		}
コード例 #29
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;
                }
            }
        }
コード例 #30
0
 public void SetProxy(IAopProxy target)
 {
     this.target = (IPersistentObject)target;
 }
コード例 #31
0
        /// <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());
        }
コード例 #32
0
 public void SetProxy(IAopProxy target)
 {
 //    this.target = target;
 }
コード例 #33
0
 public void SetProxy(Puzzle.NAspect.Framework.IAopProxy target)
 {
     this.target = target;
 }
コード例 #34
0
 public void SetProxy(IAopProxy target)
 {
     proxy = target;
 }
コード例 #35
0
 public void SetProxy(IAopProxy target)
 {
     proxy = target;
 }
コード例 #36
0
 /// <summary>
 /// Assigns a proxy instance to the mixin.
 /// </summary>
 /// <param name="target"></param>
 public void SetProxy(IAopProxy target)
 {
 }
コード例 #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;
                }
            }
        }
コード例 #39
0
 public void SetProxy(IAopProxy target)
 {
     this.target = target;
 }
コード例 #40
0
 //called when ctor of target is intercepted
 public void SetProxy(IAopProxy target)
 {
     targetList       = (IList)target;
     interceptor.List = targetList;
 }