Esempio n. 1
0
        public override void ResolveEntity()
        {
            Debug.Assert(NodeType != XmlNodeType.EntityReference);

            if (NodeType != XmlNodeType.EntityReference)
            {
                throw new InvalidOperationException(Res.GetString(Res.Xml_InvalidOperation));
            }
        }
Esempio n. 2
0
        // Whole Content Read Methods
        public override string ReadString()
        {
            string result = string.Empty;

            if (NodeType == XmlNodeType.Element || NodeType == XmlNodeType.Attribute || this.currentInfo == this.attributeValue)
            {
                if (this.mainNode.IsEmptyTag)
                {
                    return(result);
                }
                if (!Read())
                {
                    throw new InvalidOperationException(Res.GetString(Res.Xml_InvalidOperation));
                }
            }

            StringBuilder sb    = null;
            bool          first = true;

            while (true)
            {
                switch (NodeType)
                {
                case XmlNodeType.Text:
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
//              case XmlNodeType.CharacterEntity:
                    if (first)
                    {
                        result = this.Value;
                        first  = false;
                    }
                    else
                    {
                        if (sb == null)
                        {
                            sb = new StringBuilder(result);
                        }
                        sb.Append(this.Value);
                    }
                    if (!Read())
                    {
                        throw new InvalidOperationException(Res.GetString(Res.Xml_InvalidOperation));
                    }
                    break;

                default:
                    return((sb == null) ? result : sb.ToString());
                }
            }
        }