Beispiel #1
0
 public virtual void OnTargetTypeDefinition(TargetTypeDefinition targetType)
 {
     if (targetType.TargetStrategy == TargetStrategyEnum.SingleType)
     {
         OnTypeReferenceDefinition(targetType.SingleType);
     }
     else if (targetType.TargetStrategy == TargetStrategyEnum.Assignable)
     {
         OnTypeReferenceDefinition(targetType.AssignType);
     }
     else if (targetType.TargetStrategy == TargetStrategyEnum.Namespace)
     {
         OnTargetNamespace(targetType.NamespaceRoot);
         OnExcludedTypes(targetType.Excludes);
     }
     else if (targetType.TargetStrategy == TargetStrategyEnum.Custom)
     {
         OnTypeReferenceDefinition(targetType.CustomMatcherType);
     }
 }
Beispiel #2
0
        protected virtual IClassMatcher ObtainCustomMatcher(TargetTypeDefinition target)
        {
            Type customType = target.CustomMatcherType.ResolvedType;

            IClassMatcher matcher = GetCustomMatcherFromCache(customType);

            try
            {
                matcher = (IClassMatcher)Activator.CreateInstance(customType);
            }
            catch (InvalidCastException ex)
            {
                throw new MatcherException("Error trying to cast your custom class matcher to IClassMatcher", ex);
            }
            catch (Exception ex)
            {
                throw new MatcherException("Error trying to instantiate your custom class matcher", ex);
            }

            RegisterMatcherInCache(matcher, customType);

            return(matcher);
        }
        public override void OnTargetTypeDefinition(TargetTypeDefinition targetType)
        {
            if (targetType.TargetStrategy == TargetStrategyEnum.SingleType)
            {
                AssertNotInterface(
                    targetType.LexicalInfo, targetType.SingleType.ResolvedType,
                    MIXIN_CANT_BE_INTERFACE);
            }
            else if (targetType.TargetStrategy == TargetStrategyEnum.Namespace)
            {
            }
            else if (targetType.TargetStrategy == TargetStrategyEnum.Assignable)
            {
            }
            else if (targetType.TargetStrategy == TargetStrategyEnum.Custom)
            {
                // TODO: Move IClassMatcher and etc to another assembly
                // to prevent cyclic references.
//				AssertAssignableFrom(
//					targetType.LexicalInfo, typeof(IClassMatcher),
//					targetType.SingleType.ResolvedType, MIXIN_CANT_BE_INTERFACE);
            }
        }
		private void SerializeTargetType( TargetTypeDefinition def )
		{
			Push( Document.CreateNode(XmlNodeType.Element, "singletype", null) );
			SerializeTypeReference( def.SingleType );
			Pop();
		}
Beispiel #5
0
    protected void aspects(
        EngineConfiguration conf
        ) //throws RecognitionException, TokenStreamException
    {
        Token a        = null;
        Token aspectId = null;

        AspectDefinition     aspect = null;
        TargetTypeDefinition target = null;
        TypeReference        tr     = null;


        try {              // for error handling
            a = LT(1);
            match(ASPECT);
            aspectId = LT(1);
            match(ID);
            match(FOR);

            aspect = new AspectDefinition(ToLexicalInfo(a), aspectId.getText());
            conf.Aspects.Add(aspect);

            {
                switch (LA(1))
                {
                case ID:
                {
                    tr = type_name_def();

                    target = new TargetTypeDefinition(tr);
                    target.TargetStrategy = TargetStrategyEnum.SingleType;
                    aspect.TargetType     = target;

                    break;
                }

                case LBRACK:
                {
                    match(LBRACK);

                    target            = new TargetTypeDefinition( );
                    aspect.TargetType = target;
                    String namespaceRegEx = null;

                    {
                        switch (LA(1))
                        {
                        case ASSIGNFROM:
                        {
                            match(ASSIGNFROM);
                            match(LCURLY);
                            tr = type_name_def();
                            match(RCURLY);

                            target.TargetStrategy = TargetStrategyEnum.Assignable;
                            target.AssignType     = tr;

                            break;
                        }

                        case CUSTOMMATCHER:
                        {
                            match(CUSTOMMATCHER);
                            match(LCURLY);
                            tr = type_name_def();
                            match(RCURLY);

                            target.TargetStrategy    = TargetStrategyEnum.Custom;
                            target.CustomMatcherType = tr;

                            break;
                        }

                        case ID:
                        {
                            {
                                namespaceRegEx = identifier();

                                target.TargetStrategy = TargetStrategyEnum.Namespace;
                                target.NamespaceRoot  = namespaceRegEx;

                                {
                                    switch (LA(1))
                                    {
                                    case EXCLUDES:
                                    {
                                        match(EXCLUDES);
                                        match(LCURLY);
                                        type_list(target.Excludes);
                                        match(RCURLY);
                                        break;
                                    }

                                    case RBRACK:
                                    {
                                        break;
                                    }

                                    default:
                                    {
                                        throw new NoViableAltException(LT(1), getFilename());
                                    }
                                    }
                                }
                            }
                            break;
                        }

                        default:
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }
                        }
                    }
                    match(RBRACK);
                    break;
                }

                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                }
            }
            {
                {                    // ( ... )*
                    for (;;)
                    {
                        if ((LA(1) == INCLUDE))
                        {
                            include(aspect);
                        }
                        else
                        {
                            goto _loop33_breakloop;
                        }
                    }
                    _loop33_breakloop :;
                }                    // ( ... )*
                {                    // ( ... )*
                    for (;;)
                    {
                        if ((LA(1) == POINTCUT))
                        {
                            pointcut(aspect);
                        }
                        else
                        {
                            goto _loop35_breakloop;
                        }
                    }
                    _loop35_breakloop :;
                }                    // ( ... )*
            }
            match(END);
        }
        catch (RecognitionException ex)
        {
            reportError(ex);
            consume();
            consumeUntil(tokenSet_4_);
        }
    }
		public virtual void OnTargetTypeDefinition(TargetTypeDefinition targetType)
		{
			if (targetType.TargetStrategy == TargetStrategyEnum.SingleType)
			{
				OnTypeReferenceDefinition( targetType.SingleType );
			}
			else if (targetType.TargetStrategy == TargetStrategyEnum.Assignable)
			{
				OnTypeReferenceDefinition( targetType.AssignType );
			}
			else if (targetType.TargetStrategy == TargetStrategyEnum.Namespace)
			{
				OnTargetNamespace( targetType.NamespaceRoot );
				OnExcludedTypes( targetType.Excludes );
			}
			else if (targetType.TargetStrategy == TargetStrategyEnum.Custom)
			{
				OnTypeReferenceDefinition( targetType.CustomMatcherType );
			}
		}
Beispiel #7
0
 private void SerializeTargetType(TargetTypeDefinition def)
 {
     Push(Document.CreateNode(XmlNodeType.Element, "singletype", null));
     SerializeTypeReference(def.SingleType);
     Pop();
 }