Ejemplo n.º 1
0
        /// <summary>
        /// Writes the start element.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        /// <remarks>The implementation of <see cref="HtmlWriter"/> should
        /// maintain a stack of elements (tags) written. The implementation of
        /// this method should store the tag on this stack so
        /// the <see cref="WriteEndElement"/> would be able to write
        /// the closing part of the element later on.</remarks>
        /// <seealso cref="WriteEndElement"/>
        public override void WriteStartElement(string name)
        {
            CheckClosed();

            _nestedTokens.Push(new Token(name));
            _writer.Write('<');
            _writer.Write(name);
        }
Ejemplo n.º 2
0
        private void StackCheck(Token token)
        {
            DropStackToTag();

            switch (token.Type)
            {
            case HtmlNodeType.ClosedTag:
            case HtmlNodeType.Comment:
            case HtmlNodeType.Text:
            case HtmlNodeType.Whitespace:
            {
                if (HtmlNodeType.Tag == _nestedTokens.Top.Type)
                {
                    _nestedTokens.Push(token);
                }
                else
                {
                    _nestedTokens.Swap(token);
                }
                break;
            }

            case HtmlNodeType.Tag:
            {
                if (!Tag.IsAtomic(token.Name))
                {
                    _nestedTokens.Push(token);
                }
                else
                {
                    _nestedTokens.Swap(token);
                }
                break;
            }

            case HtmlNodeType.EndTag:
            {
                _nestedTokens.Push(token);
                break;
            }

            default:
                throw new HtmlException(RD.GetString("tagUnknown"));
            }
        }