示例#1
0
        /// <summary>
        /// Sets the inherited items of the class.
        /// </summary>
        private void SetInheritedItems()
        {
            // Pull out the name of the base class and any implemented interfaces
            // from the declaration of this class.
            bool colon      = false;
            bool comma      = false;
            var  interfaces = new List <string>();

            this.baseClass.Value = string.Empty;

            for (Token token = this.FindFirstChildToken(); token != null; token = token.FindNextSiblingToken())
            {
                if (colon)
                {
                    if (token.Text.Length >= 2 &&
                        token.Text[0] == 'I' &&
                        char.IsUpper(token.Text[1]))
                    {
                        interfaces.Add(CodeParser.TrimType(token.Text));
                    }
                    else
                    {
                        this.baseClass.Value = CodeParser.TrimType(token.Text);
                    }

                    colon = false;
                }
                else if (comma)
                {
                    interfaces.Add(CodeParser.TrimType(token.Text));
                    comma = false;
                }
                else
                {
                    if (token.TokenType == TokenType.Where)
                    {
                        break;
                    }
                    else if (token.Text == ":")
                    {
                        if (this.baseClass.Value.Length > 0)
                        {
                            break;
                        }
                        else
                        {
                            colon = true;
                        }
                    }
                    else if (token.TokenType == TokenType.Comma)
                    {
                        comma = true;
                    }
                }
            }

            this.implementedInterfaces.Value = interfaces.AsReadOnly();
        }
示例#2
0
        /// <summary>
        /// Initializes the element.
        /// </summary>
        private void Init()
        {
            this.namespaceType.Value = this.alias.Value = string.Empty;

            // Find the 'using' keyword.
            Token usingKeyword = this.FindFirstChild <UsingDirectiveToken>();

            if (usingKeyword != null)
            {
                // Move past it.
                Token index = usingKeyword.FindNextSiblingToken();
                if (index != null)
                {
                    // This word is usually the namespace type, unless an alias is defined.
                    this.namespaceType.Value = CodeParser.TrimType(CodeParser.GetFullName(this.Document, this, index, out index));

                    // Now see if the next word is an equals sign.
                    index = index.FindNextSiblingToken();

                    if (index != null)
                    {
                        if (index.Text == "=")
                        {
                            // Get the word after the equals sign, which will be the namespace.
                            index = index.FindNextSiblingToken();

                            if (index != null)
                            {
                                // Set the alias and the namespace.
                                this.alias.Value         = this.namespaceType.Value;
                                this.namespaceType.Value = CodeParser.TrimType(index.Text);
                            }
                        }
                    }
                }
            }
        }