public void SelectiveApplication()
        {
            SerializablePerson target = new SerializablePerson();

            target.SetAge(27);
            NopInterceptor      nop             = new NopInterceptor();
            ControlFlowPointcut cflow           = new ControlFlowPointcut(typeof(One));
            IPointcut           settersUnderOne = Pointcuts.Intersection(SetterPointcut.Instance, cflow);
            ProxyFactory        pf      = new ProxyFactory(target);
            IPerson             proxied = (IPerson)pf.GetProxy();

            pf.AddAdvisor(new DefaultPointcutAdvisor(settersUnderOne, nop));

            // Not advised, not under One
            target.SetAge(16);
            Assert.AreEqual(0, nop.Count);

            // Not advised; under One but not a setter
            Assert.AreEqual(16, new One().GetAge(proxied));
            Assert.AreEqual(0, nop.Count);

            // Won't be advised
            new One().Set(proxied);
            Assert.AreEqual(1, nop.Count);

            // We saved most evaluations
            Assert.AreEqual(1, cflow.EvaluationCount);
        }
Ejemplo n.º 2
0
        public AppliedAdvice(IAdvice advice, IPointcut pointcut)
        {
            Guard.ArgumentIsNotNull(() => advice, () => pointcut);

            Advice    = advice;
            _pointcut = pointcut;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Signature aspect ctor.
 /// </summary>
 /// <param name="name">Name of the aspect</param>
 /// <param name="targetName">Signature of the target type</param>
 /// <param name="mixins">Array of <c>System.Type</c>s to mixin</param>
 /// <param name="pointcuts">Array of IPointcut instances</param>
 public SignatureAspect(string name, string targetName, Type[] mixins, IPointcut[] pointcuts)
 {
     Name = name;
     TargetTypeSignature = targetName;
     Mixins = new ArrayList(mixins);
     Pointcuts = new ArrayList(pointcuts);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Attribute aspect Ctor.
 /// </summary>
 /// <param name="Name">Name of the aspect.</param>
 /// <param name="attributeType">Type of the attribute to match.</param>
 /// <param name="mixins">Type[] array of mixin types</param>
 /// <param name="pointcuts">IPointcut[] array of pointcut instances</param>
 public AttributeAspect(string Name, Type attributeType, Type[] mixins, IPointcut[] pointcuts)
 {
     this.Name = Name;
     Mixins = new ArrayList(mixins);
     Pointcuts = new ArrayList(pointcuts);
     Targets.Add(new AspectTarget(attributeType, AspectTargetType.Attribute));
 }
        public PresentationPointcut(PresentationAspect aspect, IPointcut pointcut)
        {
            this.aspect = aspect;

            this.Name = pointcut.Name;

            foreach (PointcutTarget target in pointcut.Targets)
            {
                PresentationPointcutTarget presTarget = new PresentationPointcutTarget(this, target);
                this.Targets.Add(presTarget);
            }

            foreach (object interceptor in pointcut.Interceptors)
            {
                string typeName = "";
                if (interceptor is Type)
                {
                    typeName = ((Type)interceptor).FullName;
                }
                else
                {
                    typeName = (string)interceptor;
                }

                PresentationInterceptor presInterceptor = new PresentationInterceptor(this, typeName);
                this.Interceptors.Add(presInterceptor);
            }
        }
Ejemplo n.º 6
0
            public PointcutNode(IPointcut pointcut, string expression, IEnumerable <AssemblyNode> asmNodes) : base(asmNodes)
            {
                _expression = expression;
                _pointcut   = pointcut;

                Icon = CodeTreeIcons.Pointcut.ToImageSource();
            }
Ejemplo n.º 7
0
        /// <summary>
        /// Can the supplied <paramref name="pointcut"/> apply at all on the
        /// supplied <paramref name="targetType"/>?
        /// </summary>
        /// <remarks>
        /// <p>
        /// This is an important test as it can be used to optimize out a
        /// pointcut for a class.
        /// </p>
        /// <p>
        /// Invoking this method with a <paramref name="targetType"/> that is
        /// an interface type will always yield a <see langword="false"/>
        /// return value.
        /// </p>
        /// </remarks>
        /// <param name="pointcut">The pointcut being tested.</param>
        /// <param name="targetType">The class being tested.</param>
        /// <param name="proxyInterfaces">
        /// The interfaces being proxied. If <see langword="null"/>, all
        /// methods on a class may be proxied.
        /// </param>
        /// <param name="hasIntroductions">whether or not the advisor chain for the target object includes any introductions.</param>
        /// <returns>
        /// <see langword="true"/> if the pointcut can apply on any method.
        /// </returns>
        public static bool CanApply(IPointcut pointcut, Type targetType, Type[] proxyInterfaces, bool hasIntroductions)
        {
            if (!pointcut.TypeFilter.Matches(targetType))
            {
                return(false);
            }

            // It may apply to the class
            // Check whether it can apply on any method
            // Checks public methods, including inherited methods
            MethodInfo[] methods = targetType.GetMethods();
            for (int i = 0; i < methods.Length; ++i)
            {
                MethodInfo m = methods[i];
                // If we're looking only at interfaces and this method
                // isn't on any of them, skip it
                if (proxyInterfaces != null &&
                    !ReflectionUtils.MethodIsOnOneOfTheseInterfaces(m, proxyInterfaces))
                {
                    continue;
                }
                if (pointcut.MethodMatcher.Matches(m, targetType))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Signature aspect ctor.
 /// </summary>
 /// <param name="name">Name of the aspect</param>
 /// <param name="targetName">Signature of the target type</param>
 /// <param name="mixins">Array of <c>System.Type</c>s to mixin</param>
 /// <param name="pointcuts">Array of IPointcut instances</param>
 public SignatureAspect(string name, string targetName, Type[] mixins, IPointcut[] pointcuts)
 {
     Name = name;
     Mixins = new ArrayList(mixins);
     Pointcuts = new ArrayList(pointcuts);
     Targets.Add(new AspectTarget(targetName, AspectTargetType.Signature));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Attribute aspect Ctor.
 /// </summary>
 /// <param name="name">Name of the aspect.</param>
 /// <param name="targets">Type[] array of aspect targets</param>
 /// <param name="mixins">Type[] array of mixin types</param>
 /// <param name="pointcuts">IPointcut[] array of pointcut instances</param>
 public GenericAspect(string name, AspectTarget[] targets, Type[] mixins, IPointcut[] pointcuts)
 {
     Name = name;
     Targets = new ArrayList(targets);
     Mixins = new ArrayList(mixins);
     Pointcuts = new ArrayList(pointcuts);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Attribute aspect Ctor.
 /// </summary>
 /// <param name="Name">Name of the aspect.</param>
 /// <param name="attributeType">Type of the attribute to match.</param>
 /// <param name="mixins">Type[] array of mixin types</param>
 /// <param name="pointcuts">IPointcut[] array of pointcut instances</param>
 public AttributeAspect(string Name, Type attributeType, Type[] mixins, IPointcut[] pointcuts)
 {
     this.Name = Name;
     AttributeType = attributeType;
     Mixins = new ArrayList(mixins);
     Pointcuts = new ArrayList(pointcuts);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Interface aspect Ctor.
 /// </summary>
 /// <param name="Name">Name of the aspect.</param>
 /// <param name="interfaceType">Type of the interface to match.</param>
 /// <param name="mixins">Type[] array of mixin types</param>
 /// <param name="pointcuts">IPointcut[] array of pointcut instances</param>
 public InterfaceAspect(string Name, Type interfaceType, Type[] mixins, IPointcut[] pointcuts)
 {
     this.Name = Name;
     Mixins = new ArrayList(mixins);
     Pointcuts = new ArrayList(pointcuts);
     Targets.Add(new AspectTarget(interfaceType, AspectTargetType.Interface));
 }
        public PresentationPointcutTarget(IPointcut pointcut, PointcutTarget target)
        {
            this.pointcut = pointcut;

            this.Exclude    = target.Exclude;
            this.Signature  = target.Signature;
            this.TargetType = target.TargetType;
        }
        public PresentationPointcutTarget(IPointcut pointcut, PointcutTarget target)
        {
            this.pointcut = pointcut;

            this.Exclude = target.Exclude;
            this.Signature = target.Signature;
            this.TargetType = target.TargetType;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 构造方法。
        /// </summary>
        public PointcutAspect(IPointcut pointcut, IPointcutAdvice advice)
        {
            Check.MustNotNull(pointcut, "pointcut");
            Check.MustNotNull(advice, "advice");

            this.Pointcut = pointcut;
            this.Advice = advice;
        }
        public void Deserialization()
        {
            IPointcut deserializedVersion
                = (IPointcut)SerializationTestUtils.SerializeAndDeserialize(
                      TruePointcut.True);

            Assert.IsTrue(Object.ReferenceEquals(TruePointcut.True, deserializedVersion),
                          "Singleton instance not being deserialized correctly");
        }
Ejemplo n.º 16
0
        public PointcutDefinitionException(AspectDefinition aspect, IPointcut pointcut, string message, Exception innerException)
            : base(FormatMessage(aspect, pointcut, message), innerException)
        {
            Contract.Requires(aspect != null);
            Contract.Requires(pointcut != null);

            Aspect   = aspect;
            Pointcut = pointcut;
        }
Ejemplo n.º 17
0
        public Crosscutting(IPointcut pointcut, IEnumerable <IOrdering> orderings, string name)
        {
            ArgumentUtility.CheckNotNull("pointcut", pointcut);
            ArgumentUtility.CheckNotNull("orderings", orderings);
            ArgumentUtility.CheckNotNullOrEmpty("name", name);

            _pointcut  = pointcut;
            _orderings = orderings;
            _name      = name;
        }
Ejemplo n.º 18
0
        public IEnumerable <T> GetPointcutForRef <T>(string name, IPointcut referrer) where T : IPointcut
        {
            var pointcuts = GetPointcuts(name).OfType <T>().ToArray();

            if (!pointcuts.Any())
            {
                throw new IncorrectPointcutRefTypeException(this, referrer, name, typeof(T));
            }

            return(pointcuts);
        }
Ejemplo n.º 19
0
        public object BuildFor(IPointcut pointcut)
        {
            var method = pointcut.GetType().GetMethod("Where" + Property);

            if (method == null)
            {
                throw new UnkonwnCriteriaSaqlException(this, pointcut);
            }

            var parameters = method.GetParameters();

            object[] args;

            if (parameters.Length > 0 && parameters[0].ParameterType == typeof(AspectDefinition))
            {
                args = new[] { Aspect };
            }
            else
            {
                if (parameters.Length > 0 && Value == null)
                {
                    throw new MissingArgumentSaqlException(this);
                }

                if (parameters.Length == 0 && Value != null)
                {
                    throw new UnexpectedArgumentSaqlException(this);
                }

                if (parameters.Length == 0)
                {
                    args = new object[0];
                }
                else
                {
                    var param = parameters[0];

                    var arg = Construct(param.ParameterType);
                    args = new[] { Value.Build(arg) };
                }
            }

            try
            {
                method.Invoke(pointcut, args);
            }
            catch (TargetInvocationException e)
            {
                throw e.InnerException;
            }

            return(pointcut);
        }
Ejemplo n.º 20
0
 public bool IsPointcutMethod(System.Reflection.MethodInfo info, IKernel kernel)
 {
     foreach (String id in PointcutComponents.Keys)
     {
         IPointcut pcuts = (IPointcut)kernel.Resolve(
             id, typeof(IPointcut));
         if (pcuts.IsPointcutMethod(info))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 21
0
        public void Add <TAdvice>(IPointcut pointcut)
            where TAdvice : class, IAdvice
        {
            //All advices are registered in the IOC container, so we can easily let the container create our advices

            //LazyAdvice: at the moment of registering the advices, the IOC container itself might not be build up completely.
            //The LazyAdvice allows us to delay the creation of the required advice until the moment
            //that the advice is actually needed (and the IOC container is completely builded).
            var advice = new LazyAdvice <TAdvice>(ResolveAdvice <TAdvice>);

            Add(advice, pointcut);
            _blockedTypes.Add(typeof(TAdvice));
        }
Ejemplo n.º 22
0
 public bool TypeContainPointcut(Type type, IKernel kernel)
 {
     foreach (String id in PointcutComponents.Keys)
     {
         IPointcut pcuts = (IPointcut)kernel.Resolve(
             id, typeof(IPointcut));
         if (pcuts.TypeContainPointcut(type))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 23
0
        public Crosscutting(IPointcut pointcut, IEnumerable <IOrdering> orderings, int priority, Type type, string role)
        {
            ArgumentUtility.CheckNotNull("pointcut", pointcut);
            ArgumentUtility.CheckNotNull("orderings", orderings);
            ArgumentUtility.CheckNotNull("type", type);
            ArgumentUtility.CheckNotNullOrEmpty("role", role);

            _pointcut  = pointcut;
            _orderings = orderings;
            _priority  = priority;
            _type      = type;
            _role      = role;
        }
        private static void AddInterceptors(ITypedAspect aspect, IList pointcuts)
        {
            ArrayList methodsList = new ArrayList();

            MethodInfo[] methods =
                aspect.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
                                            BindingFlags.DeclaredOnly);
            foreach (MethodInfo method in methods)
            {
                object[] interceptorAttributes = method.GetCustomAttributes(typeof(InterceptorAttribute), false);
                if (interceptorAttributes != null && interceptorAttributes.Length > 0)
                {
                    methodsList.Add(method);
                }
            }

            methodsList.Sort(new InterceptorMethodSorter());

            foreach (MethodInfo method in methodsList)
            {
                object[] interceptorAttributes = method.GetCustomAttributes(typeof(InterceptorAttribute), false);
                if (interceptorAttributes != null)
                {
                    InterceptorAttribute interceptor         = (InterceptorAttribute)interceptorAttributes[0];
                    IPointcut            pointcut            = null;
                    Delegate             interceptorDelegate = CreateDelegate(aspect, method);
                    if (interceptor.TargetAttribute != null)
                    {
                        pointcut = new AttributePointcut(interceptor.TargetAttribute, interceptorDelegate);
                    }
                    else if (interceptor.TargetSignature != null)
                    {
                        pointcut = new SignaturePointcut(interceptor.TargetSignature, interceptorDelegate);
                    }
                    else
                    {
                        throw new Exception("Interceptor attribute does not contain any target info");
                    }
                    pointcuts.Add(pointcut);
                }
            }
        }
Ejemplo n.º 25
0
        public PointcutNode(IPointcut pointcut)
            : base(pointcut.Name)
        {
            this.pointcut = pointcut;

            this.ImageIndex         = 6;
            this.SelectedImageIndex = 6;

            foreach (PointcutTarget target in pointcut.Targets)
            {
                PointcutTargetNode targetNode = new PointcutTargetNode(target);
                this.Nodes.Add(targetNode);
            }

            foreach (PresentationInterceptor interceptor in pointcut.Interceptors)
            {
                InterceptorNode interceptorNode = new InterceptorNode(interceptor);
                this.Nodes.Add(interceptorNode);
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Performs the least expensive check for a match.
 /// </summary>
 /// <param name="pointcut">
 /// The <see cref="Spring.Aop.IPointcut"/> to be evaluated.
 /// </param>
 /// <param name="method">The candidate method.</param>
 /// <param name="targetType">
 /// The target <see cref="System.Type"/>.
 /// </param>
 /// <param name="args">The arguments to the method</param>
 /// <returns><see langword="true"/> if there is a runtime match.</returns>
 /// <seealso cref="Spring.Aop.IMethodMatcher.Matches(MethodInfo, Type)"/>
 public static bool Matches(
     IPointcut pointcut, MethodInfo method, Type targetType, object[] args)
 {
     if (pointcut != null)
     {
         if (pointcut == TruePointcut.True)
         {
             return(true);
         }
         if (pointcut.TypeFilter.Matches(targetType))
         {
             IMethodMatcher mm = pointcut.MethodMatcher;
             if (mm.Matches(method, targetType))
             {
                 return(mm.IsRuntime ? mm.Matches(method, targetType, args) : true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 27
0
        public static ICrosscutting GetCrosscutting(
            IEnumerable <IOrdering> orderings = null,
            IPointcut pointcut = null,
            string name        = "Aspect",
            string role        = StandardRoles.Unspecified,
            int priority       = 0)
        {
            orderings = orderings ?? new IOrdering[0];
            pointcut  = pointcut ?? GetPointcut();

            var crosscutting = MockRepository.GenerateStub <ICrosscutting>();

            crosscutting.Stub(x => x.Orderings).Return(orderings);
            crosscutting.Stub(x => x.Pointcut).Return(pointcut);
            crosscutting.Stub(x => x.Name).Return(name);
            crosscutting.Stub(x => x.Role).Return(role);
            crosscutting.Stub(x => x.Priority).Return(priority);

            return(crosscutting);
        }
Ejemplo n.º 28
0
        public PointcutNode(IPointcut pointcut)
            : base(pointcut.Name)
        {
            this.pointcut = pointcut;

            this.ImageIndex = 6;
            this.SelectedImageIndex = 6;

            foreach (PointcutTarget target in pointcut.Targets)
            {
                PointcutTargetNode targetNode = new PointcutTargetNode(target);
                this.Nodes.Add(targetNode);
            }

            foreach (PresentationInterceptor interceptor in pointcut.Interceptors)
            {
                InterceptorNode interceptorNode = new InterceptorNode(interceptor);
                this.Nodes.Add(interceptorNode);
            }
        }
        public void Registered()
        {
            Assert.IsNotNull(NamespaceParserRegistry.GetParser("http://www.springframework.net/aop"));


            IPointcut pointcut = ctx["getDescriptionCalls"] as IPointcut;

            Assert.IsNotNull(pointcut);
            Assert.IsFalse(AopUtils.IsAopProxy(pointcut));


            ITestObject testObject = ctx["testObject"] as ITestObject;

            Assert.IsNotNull(testObject);
            Assert.IsTrue(AopUtils.IsAopProxy(testObject), "Object should be an AOP proxy");

            IAdvised advised = testObject as IAdvised;

            Assert.IsNotNull(advised);
            IAdvisor[] advisors = advised.Advisors;
            Assert.IsTrue(advisors.Length > 0, "Advisors should not be empty");
        }
        public PresentationPointcut(PresentationAspect aspect, IPointcut pointcut)
        {
            this.aspect = aspect;

            this.Name = pointcut.Name;

            foreach (PointcutTarget target in pointcut.Targets)
            {
                PresentationPointcutTarget presTarget = new PresentationPointcutTarget(this, target);
                this.Targets.Add(presTarget);
            }

            foreach (object interceptor in pointcut.Interceptors)
            {
                string typeName = "";
                if (interceptor is Type)
                    typeName = ((Type)interceptor).FullName;
                else
                    typeName = (string)interceptor;

                PresentationInterceptor presInterceptor = new PresentationInterceptor(this, typeName);
                this.Interceptors.Add(presInterceptor);
            }
        }
Ejemplo n.º 31
0
        public void BuildFromSaql(AspectDefinition aspect, string saql, IPointcut pointcut)
        {
            try
            {
                var lexer  = new PointcutLexer(new ANTLRStringStream(saql));
                var parser = new PointcutParser(new CommonTokenStream(lexer));

                var walker = new PointcutWalker(aspect, pointcut, new CommonTreeNodeStream(parser.pointcut().Tree));

                var node = walker.pointcut().value;
                if (node != null)
                {
                    node.Build(pointcut);
                }
            }
            catch (SheepAspectException e)
            {
                throw new PointcutDefinitionException(aspect, pointcut, e);
            }
            catch (Exception e)
            {
                throw new PointcutDefinitionException(aspect, pointcut, "Error parsing pointcut: " + e.Message, e);
            }
        }
 public ObjectFactoryTransactionAttributeSourceAdvisor()
 {
     _pointcut = new TransactonAttributeSourcePointcut(this);
 }
Ejemplo n.º 33
0
 public virtual bool Visit(IPointcut pointcut, JoinPoint joinPoint)
 {
     return(pointcut.Accept(this, joinPoint));
 }
Ejemplo n.º 34
0
 public PointcutProperties(IPointcut pointcut)
 {
     this.pointcut = pointcut;
 }
Ejemplo n.º 35
0
 public PointcutDefinitionException(AspectDefinition aspect, IPointcut pointcut, SheepAspectException innerException)
     : this(aspect, pointcut, FormatMessage(aspect, pointcut, innerException.Message), innerException)
 {
 }
Ejemplo n.º 36
0
 protected static string FormatMessage(AspectDefinition aspect, IPointcut pointcut, string message)
 {
     return(aspect.Name + "::" + pointcut.Name + "\r\n" + message);
 }
Ejemplo n.º 37
0
        /// <summary> 
        /// Can the supplied <paramref name="pointcut"/> apply at all on the
        /// supplied <paramref name="targetType"/>?
        /// </summary>
        /// <remarks>
        /// <p>
        /// This is an important test as it can be used to optimize out a
        /// pointcut for a class.
        /// </p>
        /// <p>
        /// Invoking this method with a <paramref name="targetType"/> that is
        /// an interface type will always yield a <see langword="false"/>
        /// return value.
        /// </p>
        /// </remarks>
        /// <param name="pointcut">The pointcut being tested.</param>
        /// <param name="targetType">The class being tested.</param>
        /// <param name="proxyInterfaces">
        /// The interfaces being proxied. If <see langword="null"/>, all
        /// methods on a class may be proxied.
        /// </param>
        /// <param name="hasIntroductions">whether or not the advisor chain for the target object includes any introductions.</param>
        /// <returns>
        /// <see langword="true"/> if the pointcut can apply on any method.
        /// </returns>
        public static bool CanApply(IPointcut pointcut, Type targetType, Type[] proxyInterfaces, bool hasIntroductions)
        {
            if (!pointcut.TypeFilter.Matches(targetType))
            {
                return false;
            }

            // It may apply to the class
            // Check whether it can apply on any method
            // Checks public methods, including inherited methods
            MethodInfo[] methods = targetType.GetMethods();
            for (int i = 0; i < methods.Length; ++i)
            {
                MethodInfo m = methods[i];
                // If we're looking only at interfaces and this method
                // isn't on any of them, skip it
                if (proxyInterfaces != null
                    && !ReflectionUtils.MethodIsOnOneOfTheseInterfaces(m, proxyInterfaces))
                {
                    continue;
                }
                if (pointcut.MethodMatcher.Matches(m, targetType))
                {
                    return true;
                }
            }
            return false;
        }
 public PresentationPointcutTarget(IPointcut pointcut)
 {
     this.pointcut = pointcut;
 }
		/// <summary>
		/// Creates a new instance of the
		/// <see cref="Spring.Aop.Support.DefaultPointcutAdvisor"/>
		/// class for the supplied <paramref name="advice"/> and
		/// <paramref name="pointcut"/>.
		/// </summary>
		/// <param name="advice">
		/// The advice to use.
		/// </param>
		/// <param name="pointcut">
		/// The pointcut to use.
		/// </param>
		public DefaultPointcutAdvisor(IPointcut pointcut, IAdvice advice)
		{
			this.pointcut = pointcut;
			Advice = advice;
		}
Ejemplo n.º 40
0
 /// <summary> 
 /// Can the supplied <paramref name="pointcut"/> apply at all on the
 /// supplied <paramref name="targetType"/>?
 /// </summary>
 /// <remarks>
 /// <p>
 /// This is an important test as it can be used to optimize out a
 /// pointcut for a class.
 /// </p>
 /// <p>
 /// Invoking this method with a <paramref name="targetType"/> that is
 /// an interface type will always yield a <see langword="false"/>
 /// return value.
 /// </p>
 /// </remarks>
 /// <param name="pointcut">The pointcut being tested.</param>
 /// <param name="targetType">The class being tested.</param>
 /// <param name="proxyInterfaces">
 /// The interfaces being proxied. If <see langword="null"/>, all
 /// methods on a class may be proxied.
 /// </param>
 /// <returns>
 /// <see langword="true"/> if the pointcut can apply on any method.
 /// </returns>
 public static bool CanApply(IPointcut pointcut, Type targetType, Type[] proxyInterfaces)
 {
     return CanApply(pointcut, targetType, proxyInterfaces, false);
 }
 public BaseContributor(IPointcut pointcut)
 {
     Pointcut = pointcut;
 }
Ejemplo n.º 42
0
		/// <summary>
		/// Creates an <see cref="Spring.Aop.IPointcut"/> that is the
		/// intersection of the two supplied pointcuts.
		/// </summary>
		/// <param name="firstPointcut">The first pointcut.</param>
		/// <param name="secondPointcut">The second pointcut.</param>
		/// <returns>
		/// An <see cref="Spring.Aop.IPointcut"/> that is the
		/// intersection of the two supplied pointcuts.
		/// </returns>
		public static IPointcut Intersection(IPointcut firstPointcut, IPointcut secondPointcut)
		{
			return new ComposablePointcut(
				firstPointcut.TypeFilter, firstPointcut.MethodMatcher)
				.Intersection(secondPointcut);
		}
Ejemplo n.º 43
0
		/// <summary>
		/// Creates a new instance of the
		/// <see cref="Spring.Aop.Support.UnionPointcut"/> class.
		/// </summary>
		/// <param name="firstPointcut">The first pointcut.</param>
		/// <param name="secondPointcut">The second pointcut.</param>
		public UnionPointcut(IPointcut firstPointcut, IPointcut secondPointcut)
		{
			this.a = firstPointcut;
			this.b = secondPointcut;
			this.mm = new PointcutUnionMethodMatcher(this);
		}
Ejemplo n.º 44
0
 /// <summary>
 /// Changes current pointcut to intersection of the current and supplied pointcut
 /// </summary>
 /// <param name="other">pointcut to diff against</param>
 /// <returns>updated pointcut</returns>
 public virtual ComposablePointcut Intersection(IPointcut other)
 {
     _typeFilter    = TypeFilters.Intersection(_typeFilter, other.TypeFilter);
     _methodMatcher = MethodMatchers.Intersection(_methodMatcher, other.MethodMatcher);
     return(this);
 }
Ejemplo n.º 45
0
 /// <summary>
 /// Can the supplied <paramref name="pointcut"/> apply at all on the
 /// supplied <paramref name="targetType"/>?
 /// </summary>
 /// <remarks>
 /// <p>
 /// This is an important test as it can be used to optimize out a
 /// pointcut for a class.
 /// </p>
 /// <p>
 /// Invoking this method with a <paramref name="targetType"/> that is
 /// an interface type will always yield a <see langword="false"/>
 /// return value.
 /// </p>
 /// </remarks>
 /// <param name="pointcut">The pointcut being tested.</param>
 /// <param name="targetType">The class being tested.</param>
 /// <param name="proxyInterfaces">
 /// The interfaces being proxied. If <see langword="null"/>, all
 /// methods on a class may be proxied.
 /// </param>
 /// <returns>
 /// <see langword="true"/> if the pointcut can apply on any method.
 /// </returns>
 public static bool CanApply(IPointcut pointcut, Type targetType, Type[] proxyInterfaces)
 {
     return(CanApply(pointcut, targetType, proxyInterfaces, false));
 }
 public ObjectFactoryTransactionAttributeSourceAdvisor()
 {
     _pointcut = new TransactonAttributeSourcePointcut(this);
 }
Ejemplo n.º 47
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Oragon.Spring.Aop.Support.DefaultPointcutAdvisor"/>
 /// class for the supplied <paramref name="advice"/> and
 /// <paramref name="pointcut"/>.
 /// </summary>
 /// <param name="advice">
 /// The advice to use.
 /// </param>
 /// <param name="pointcut">
 /// The pointcut to use.
 /// </param>
 public DefaultPointcutAdvisor(IPointcut pointcut, IAdvice advice)
 {
     this.pointcut = pointcut;
     Advice        = advice;
 }
Ejemplo n.º 48
0
		/// <summary>
		/// Are the supplied <see cref="Spring.Aop.IPointcut"/>s equal?
		/// </summary>
		/// <param name="firstPointcut">The first pointcut.</param>
		/// <param name="secondPointcut">The second pointcut.</param>
		/// <returns>
		/// <see langword="true"/> if the supplied <see cref="Spring.Aop.IPointcut"/>s
		/// are equal.
		/// </returns>
		public static bool AreEqual(IPointcut firstPointcut, IPointcut secondPointcut)
		{
			return firstPointcut.TypeFilter == secondPointcut.TypeFilter
				&& firstPointcut.MethodMatcher == secondPointcut.MethodMatcher;
		}
Ejemplo n.º 49
0
		/// <summary>
		/// Creates a union of the two supplied pointcuts.
		/// </summary>
		/// <param name="firstPointcut">The first pointcut.</param>
		/// <param name="secondPointcut">The second pointcut.</param>
		/// <returns>
		/// The union of the two supplied pointcuts.
		/// </returns>
		/// <seealso cref="Spring.Aop.Support.UnionPointcut"/>
		public static IPointcut Union(IPointcut firstPointcut, IPointcut secondPointcut)
		{
			return new UnionPointcut(firstPointcut, secondPointcut);
		}
 public PointcutProperties(IPointcut pointcut)
 {
     this.pointcut = pointcut;
 }
Ejemplo n.º 51
0
		/// <summary>
		/// Performs the least expensive check for a match.
		/// </summary>
		/// <param name="pointcut">
		/// The <see cref="Spring.Aop.IPointcut"/> to be evaluated.
		/// </param>
		/// <param name="method">The candidate method.</param>
		/// <param name="targetType">
		/// The target <see cref="System.Type"/>.
		/// </param>
		/// <param name="args">The arguments to the method</param>
		/// <returns><see langword="true"/> if there is a runtime match.</returns>
		/// <seealso cref="Spring.Aop.IMethodMatcher.Matches(MethodInfo, Type)"/>
		public static bool Matches(
			IPointcut pointcut, MethodInfo method, Type targetType, object[] args)
		{
			if(pointcut != null) 
			{
				if (pointcut == TruePointcut.True)
				{
					return true;
				}
				if (pointcut.TypeFilter.Matches(targetType))
				{
					IMethodMatcher mm = pointcut.MethodMatcher;
					if (mm.Matches(method, targetType))
					{
						return mm.IsRuntime ? mm.Matches(method, targetType, args) : true;
					}
				}
			}
			return false;
		}
Ejemplo n.º 52
0
		/// <summary>
		/// Changes current pointcut to intersection of the current and supplied pointcut
		/// </summary>
		/// <param name="other">pointcut to diff against</param>
		/// <returns>updated pointcut</returns>
		public virtual ComposablePointcut Intersection(IPointcut other)
		{
			_typeFilter = TypeFilters.Intersection(_typeFilter, other.TypeFilter);
			_methodMatcher = MethodMatchers.Intersection(_methodMatcher, other.MethodMatcher);
			return this;
		}