/// <summary> /// Initializes the element. /// </summary> internal override void Initialize() { base.Initialize(); // Find the 'alias' keyword. Node <CsToken> aliasTokenNode = null; for (Node <CsToken> tokenNode = this.Tokens.First; !this.Tokens.OutOfBounds(tokenNode); tokenNode = tokenNode.Next) { if (tokenNode.Value.CsTokenType == CsTokenType.Alias) { aliasTokenNode = tokenNode; break; } } // Make sure we found it. if (aliasTokenNode != null && aliasTokenNode != this.Tokens.Last) { Node <CsToken> temp = aliasTokenNode.Next; if (!this.Tokens.OutOfBounds(temp)) { // Move past it. aliasTokenNode = temp; if (CodeParser.MoveToNextCodeToken(this.Tokens, ref aliasTokenNode)) { // This word is the identifier this.identifier = CodeParser.TrimType(CodeParser.GetFullName((CsDocument)this.Document, this.Tokens, aliasTokenNode, out aliasTokenNode)); } } } }
/// <summary> /// Initializes the element. /// </summary> internal override void Initialize() { base.Initialize(); // Find the 'using' keyword. Node <CsToken> usingKeywordNode = null; for (Node <CsToken> tokenNode = this.Tokens.First; !this.Tokens.OutOfBounds(tokenNode); tokenNode = tokenNode.Next) { if (tokenNode.Value.CsTokenType == CsTokenType.UsingDirective) { usingKeywordNode = tokenNode; break; } } // Make sure we found it. if (usingKeywordNode != null) { // Move past it. Node <CsToken> indexNode = usingKeywordNode.Next; if (this.Tokens.OutOfBounds(indexNode)) { indexNode = null; } if (CodeParser.MoveToNextCodeToken(this.Tokens, ref indexNode)) { // This word is usually the namespace type, unless an alias is defined. this.namespaceType = CodeParser.TrimType(CodeParser.GetFullName((CsDocument)this.Document, this.Tokens, indexNode, out indexNode)); // Now see if the next word is an equals sign. indexNode = indexNode.Next; if (this.Tokens.OutOfBounds(indexNode)) { indexNode = null; } if (CodeParser.MoveToNextCodeToken(this.Tokens, ref indexNode)) { if (indexNode.Value.Text == "=") { // Get the word after the equals sign, which will be the namespace. indexNode = indexNode.Next; if (this.Tokens.OutOfBounds(indexNode)) { indexNode = null; } if (CodeParser.MoveToNextCodeToken(this.Tokens, ref indexNode)) { // Set the alias and the namespace. this.alias = this.namespaceType; this.namespaceType = CodeParser.TrimType(indexNode.Value.Text); } } } } } }