Пример #1
0
		public override void OnInterceptorDefinition(InterceptorDefinition interceptor)
		{
			AssertIsInterceptor(interceptor.LexicalInfo, interceptor.TypeReference.ResolvedType, INVALID_INTERCEPTOR);
		}
		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);
		}
Пример #3
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);
			}
		}
Пример #4
0
		public override void OnInterceptorDefinition(InterceptorDefinition interceptor)
		{
			if (interceptor.TypeReference.TargetType == TargetTypeEnum.Type)
			{
				base.OnInterceptorDefinition(interceptor);
			}
			else
			{
				interceptor.TypeReference = 
					_interceptorKey2TypeReference[ interceptor.TypeReference.LinkRef ] as TypeReference;
			}
		}
		public void Add( InterceptorDefinition entry )
		{
			InnerList.Add( entry );
		}
	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_);
		}
	}
 public void Add(InterceptorDefinition entry)
 {
     InnerList.Add(entry);
 }