Ejemplo n.º 1
0
        internal string AttributeReader_ReadCurrentAttributeName()
        {
            if (this.state != HtmlReader.State.BeginAttribute)
            {
                this.AssertInAttribute();
                throw new InvalidOperationException("Reader must be positioned at the beginning of attribute.");
            }
            string result;

            if (this.parserToken.Attributes[this.currentAttribute].NameIndex != HtmlNameIndex.Unknown)
            {
                result = HtmlNameData.Names[(int)this.parserToken.Attributes[this.currentAttribute].NameIndex].Name;
            }
            else
            {
                if (this.parserToken.Attributes[this.currentAttribute].IsAttrNameEnd)
                {
                    return(this.parserToken.Attributes[this.currentAttribute].Name.GetString(int.MaxValue));
                }
                StringBuildSink stringBuildSink = this.GetStringBuildSink();
                this.parserToken.Attributes[this.currentAttribute].Name.WriteTo(stringBuildSink);
                do
                {
                    this.ParseToken();
                    this.currentAttribute = 0;
                    this.parserToken.Attributes[this.currentAttribute].Name.WriteTo(stringBuildSink);
                }while (!this.parserToken.Attributes[0].IsAttrNameEnd);
                result = stringBuildSink.ToString();
            }
            this.state = HtmlReader.State.EndAttributeName;
            return(result);
        }
Ejemplo n.º 2
0
        public string ReadTagName()
        {
            if (this.state != HtmlReader.State.BeginTag)
            {
                this.AssertInTag();
                throw new InvalidOperationException("Reader must be positioned at the beginning of a StartTag, EndTag or EmptyElementTag token");
            }
            string result;

            if (this.parserToken.NameIndex != HtmlNameIndex.Unknown)
            {
                result = HtmlNameData.Names[(int)this.parserToken.NameIndex].Name;
            }
            else
            {
                if (this.parserToken.IsTagNameEnd)
                {
                    return(this.parserToken.Name.GetString(int.MaxValue));
                }
                StringBuildSink stringBuildSink = this.GetStringBuildSink();
                this.parserToken.Name.WriteTo(stringBuildSink);
                do
                {
                    this.ParseToken();
                    this.parserToken.Name.WriteTo(stringBuildSink);
                }while (!this.parserToken.IsTagNameEnd);
                result = stringBuildSink.ToString();
            }
            this.state = HtmlReader.State.EndTagName;
            return(result);
        }
Ejemplo n.º 3
0
        internal string AttributeReader_ReadCurrentAttributeValue()
        {
            if (this.state != HtmlReader.State.BeginAttributeValue)
            {
                this.AssertInAttribute();
                if (this.state > HtmlReader.State.BeginAttributeValue)
                {
                    throw new InvalidOperationException("Reader must be positioned before attribute value");
                }
                if (!this.SkipToAttributeValue())
                {
                    this.state = HtmlReader.State.EndAttribute;
                    return(null);
                }
            }
            if (this.parserToken.Attributes[this.currentAttribute].IsAttrEnd)
            {
                return(this.parserToken.Attributes[this.currentAttribute].Value.GetString(int.MaxValue));
            }
            StringBuildSink stringBuildSink = this.GetStringBuildSink();

            this.parserToken.Attributes[this.currentAttribute].Value.WriteTo(stringBuildSink);
            do
            {
                this.ParseToken();
                this.currentAttribute = 0;
                this.parserToken.Attributes[0].Value.WriteTo(stringBuildSink);
            }while (!this.parserToken.Attributes[0].IsAttrEnd);
            this.state = HtmlReader.State.EndAttribute;
            return(stringBuildSink.ToString());
        }
Ejemplo n.º 4
0
        protected internal string GetString(ref Fragment fragment, int maxLength)
        {
            if (fragment.head == fragment.tail)
            {
                return(string.Empty);
            }

            if (this.IsContiguous(ref fragment))
            {
                return(new string(this.buffer, fragment.headOffset, this.GetLength(ref fragment)));
            }

            if (this.IsFragmentEmpty(ref fragment))
            {
                return(string.Empty);
            }

            if (this.stringBuildSink == null)
            {
                this.stringBuildSink = new StringBuildSink();
            }

            this.stringBuildSink.Reset(maxLength);

            this.WriteTo(ref fragment, this.stringBuildSink);

            return(this.stringBuildSink.ToString());
        }
Ejemplo n.º 5
0
        protected internal string GetString(LexicalUnit unit, int maxLength)
        {
            if (this.IsFragmentEmpty(unit))
            {
                return(string.Empty);
            }

            if (this.IsContiguous(unit))
            {
                return(new string(this.buffer, unit.headOffset, this.GetLength(unit)));
            }

            if (this.stringBuildSink == null)
            {
                this.stringBuildSink = new StringBuildSink();
            }

            this.stringBuildSink.Reset(maxLength);

            this.WriteTo(unit, this.stringBuildSink);

            return(this.stringBuildSink.ToString());
        }