public override bool Equals(object other)
        {
            PointCutDefinition otherCut = other as PointCutDefinition;

            if (otherCut == null)
            {
                return(false);
            }

            if (otherCut.Flags.Equals(Flags) &&
                otherCut.Method.Equals(Method))
            {
                return(true);
            }

            return(false);
        }
		public void BuildUsingCode()
		{
			CodeEngineBuilder builder = new CodeEngineBuilder();
			EngineConfiguration conf = builder.GetConfiguration();
			
			ImportDirective import = new ImportDirective(LexicalInfo.Empty, "AspectSharp.Tests.Classes");
			import.AssemblyReference = new AssemblyReference(LexicalInfo.Empty, "AspectSharp.Tests");
			conf.Imports.Add( import );

			conf.Mixins.Add( "key", LexicalInfo.Empty ).TypeReference = new TypeReference(LexicalInfo.Empty, "DummyMixin"); 
			conf.Interceptors.Add( "key", LexicalInfo.Empty ).TypeReference = new TypeReference(LexicalInfo.Empty, "DummyInterceptor"); 

			AspectDefinition aspect = new AspectDefinition(LexicalInfo.Empty, "McBrother");
			aspect.TargetType = new TargetTypeDefinition();
			aspect.TargetType.SingleType = new TypeReference(LexicalInfo.Empty, "DummyCustomer");
			conf.Aspects.Add(aspect);
			
			MixinDefinition mixin = new MixinDefinition(LexicalInfo.Empty);
			mixin.TypeReference = new TypeReference(LexicalInfo.Empty, "key", TargetTypeEnum.Link);
			aspect.Mixins.Add( mixin );
			
			PointCutDefinition pointcut = new PointCutDefinition(LexicalInfo.Empty, PointCutFlags.Method);
			pointcut.Method = AllMethodSignature.Instance;

			InterceptorDefinition interceptor = new InterceptorDefinition(LexicalInfo.Empty);
			interceptor.TypeReference = new TypeReference(LexicalInfo.Empty, "key", TargetTypeEnum.Link);
			pointcut.Advices.Add(interceptor);

			aspect.PointCuts.Add(pointcut);

			AspectEngine engine = builder.Build();
			AssertEngineConfiguration(engine);
		}
Exemplo n.º 3
0
		protected IMethodInterceptor[] ObtainAdvices(PointCutDefinition[] pointcuts)
		{
			ArrayList advices = new ArrayList();

			foreach (PointCutDefinition pointcut in pointcuts)
			{
				advices.AddRange(CreateInterceptor(pointcut.Advices));
			}

			return (IMethodInterceptor[]) advices.ToArray(typeof (IMethodInterceptor));
		}
		protected virtual bool FlagsMatchMethodType(MethodInfo method, PointCutDefinition pointcut)
		{
			if (!method.IsSpecialName && ((int) (pointcut.Flags & PointCutFlags.Method)) == 0)
			{
				return false;
			}

			if (method.IsSpecialName)
			{
				if (pointcut.Flags == PointCutFlags.Method)
				{
					return false;
				}

				if (((int) (pointcut.Flags & PointCutFlags.Property)) == 0)
				{
					bool isPropertyGet = method.Name.StartsWith("get");

					if ((!isPropertyGet && ((int) (pointcut.Flags & PointCutFlags.PropertyRead)) != 0) ||
						(isPropertyGet && ((int) (pointcut.Flags & PointCutFlags.PropertyWrite) != 0)))
					{
						return false;
					}
				}
			}

			return true;
		}
Exemplo n.º 5
0
		private void LoadAdvices(XmlNode inner, PointCutDefinition def)
		{
			XmlNodeList advices = inner.SelectNodes("interceptor");
			foreach (XmlNode advice in advices)
			{
				InterceptorDefinition inter = new InterceptorDefinition(LexicalInfo.Empty);
				inter.TypeReference = CreateTypeReference(advice);
				def.Advices.Add(inter);
			}
		}
Exemplo n.º 6
0
		private void ParseSignature(XmlNode inner, PointCutDefinition def)
		{
			XmlNode signature = inner.SelectSingleNode("signature");
			StringReader reader = new StringReader(signature.InnerText);
			AspectLanguageLexer lexer = new AspectLanguageLexer(reader);
			AspectParser parser = new AspectParser(lexer);
			parser.ParsePointcutSignature(def);
		}
Exemplo n.º 7
0
		public void ParsePointcutSignature(PointCutDefinition pointcut)
		{
			base.pointcuttarget(pointcut);
		}
Exemplo n.º 8
0
		private PointCutDefinition CreatePointCutDefinition(XmlNode inner)
		{
			String flags = GetRequiredAttribute(inner, "symbol");
			PointCutFlags pcflags = (PointCutFlags) Enum.Parse(typeof (PointCutFlags), flags);
			PointCutDefinition def = new PointCutDefinition(LexicalInfo.Empty, pcflags);

			ParseSignature(inner, def);
			LoadAdvices(inner, def);

			return def;
		}
	protected void pointcutsig1(
		PointCutDefinition pointcut
	) //throws RecognitionException, TokenStreamException
{
		
		
		String part1;
		MethodSignature ms = null; 
				
				
		try {      // for error handling
				{
					switch ( LA(1) )
					{
				case ALL:
					{
							match(ALL);
						
					part1 = "*"; 
					ms = AllMethodSignature.Instance; 

								break;
							}
				case ID:
							{
					part1=reg_ex(true);
					ms = new MethodSignature(part1, methodAll("*"));
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
			pointcut.Method = pointcutsig2(part1, ms);
					}
		catch (RecognitionException ex)
					{
			reportError(ex);
			consume();
			consumeUntil(tokenSet_13_);
				}
			}
		public void Add(PointCutDefinition pointcut)
		{
			InnerList.Add(pointcut);
		}
Exemplo n.º 11
0
	protected void pointcutsignature(
		PointCutDefinition pointcut
	) //throws RecognitionException, TokenStreamException
{
		
		
		try {      // for error handling
			pointcutsig1(pointcut);
		}
		catch (RecognitionException ex)
		{
			reportError(ex);
			consume();
			consumeUntil(tokenSet_13_);
		}
	}
Exemplo n.º 12
0
	protected void advice(
		PointCutDefinition pointcut
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  i = null;
		
		TypeReference tr = null;
		InterceptorDefinition interDef = null;
		
		
		try {      // for error handling
			i = LT(1);
			match(ADVICEINTERCEPTOR);
			
			interDef = new InterceptorDefinition( ToLexicalInfo(i) );
			
			match(LCURLY);
			tr=type_name_or_ref();
			
			interDef.TypeReference = tr;
			pointcut.Advices.Add( interDef );
			
			match(RCURLY);
		}
		catch (RecognitionException ex)
		{
			reportError(ex);
			consume();
			consumeUntil(tokenSet_13_);
		}
	}
Exemplo n.º 13
0
	protected void advices(
		PointCutDefinition pointcut
	) //throws RecognitionException, TokenStreamException
{
		
		
		try {      // for error handling
			{    // ( ... )*
				for (;;)
				{
					if ((LA(1)==ADVICEINTERCEPTOR))
					{
						advice(pointcut);
					}
					else
					{
						goto _loop43_breakloop;
					}
					
				}
_loop43_breakloop:				;
			}    // ( ... )*
		}
		catch (RecognitionException ex)
		{
			reportError(ex);
			consume();
			consumeUntil(tokenSet_14_);
		}
	}
Exemplo n.º 14
0
	protected void pointcut(
		AspectDefinition aspect
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  p = null;
		
		PointCutDefinition pointcut = null;
		PointCutFlags flags = PointCutFlags.Unspecified;
		
		
		try {      // for error handling
			p = LT(1);
			match(POINTCUT);
			flags=pointcutflags();
			
			pointcut = new PointCutDefinition( ToLexicalInfo(p), flags );
			aspect.PointCuts.Add( pointcut );
			
			pointcuttarget(pointcut);
			advices(pointcut);
			match(END);
		}
		catch (RecognitionException ex)
		{
			reportError(ex);
			consume();
			consumeUntil(tokenSet_11_);
		}
	}
 public void Add(PointCutDefinition pointcut)
 {
     InnerList.Add(pointcut);
 }