Esempio n. 1
0
            public DeclarationTreeInfo GetOwnerDeclaration(DeclarationTreeInfo current)
            {
                if (current == null)
                {
                    return(null);
                }
                switch (this.Owner)
                {
                case SymbolPropertyOwner.CurrentSymbol:
                    return(current);

                case SymbolPropertyOwner.CurrentScope:
                    return(current.ParentScope);

                case SymbolPropertyOwner.AncestorSymbol:
                    var ancestorSymbol = current.ParentDeclaration;
                    while (ancestorSymbol != null)
                    {
                        if (OwnerType == null || OwnerType.IsAssignableFrom(ancestorSymbol.ModelObjectType))
                        {
                            return(ancestorSymbol);
                        }
                        ancestorSymbol = ancestorSymbol.ParentDeclaration;
                    }
                    return(null);

                case SymbolPropertyOwner.AncestorScope:
                    var ancestorScope = current.Parent;
                    while (ancestorScope != null)
                    {
                        if (OwnerType == null || OwnerType.IsAssignableFrom(ancestorScope.ModelObjectType))
                        {
                            return(ancestorScope);
                        }
                        ancestorScope = ancestorScope.ParentScope;
                    }
                    return(null);

                default:
                    throw new NotImplementedException();
                }
            }
Esempio n. 2
0
            public void RegisterToOwner(DeclarationTreeInfo current)
            {
                var owner = this.GetOwnerDeclaration(current);

                owner.RegisterProperty(this);
            }