Exemplo n.º 1
0
        public override void WriteString(string data)
        {
            CheckState();
            if (current == null)
            {
                throw new InvalidOperationException("Current state is not acceptable for Text.");
            }

            if (attribute != null)
            {
                attribute.AppendChild(doc.CreateTextNode(data));
            }
            else
            {
                XmlText last = current.LastChild as XmlText;
                if (last == null)
                {
                    current.AppendChild(doc.CreateTextNode(data));
                }
                else
                {
                    last.AppendData(data);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a System.Xml.XmlText node.  If the current node is already an XmlText
        /// node it appends the text to that node.
        /// </summary>
        public override void WriteString(string text)
        {
            XmlNode parent = current;

            if (state == WriteState.Attribute)
            {
                parent = ca;
            }
            else if (state == WriteState.Element)
            {
                state = WriteState.Content;
            }
            if (state != WriteState.Attribute && state != WriteState.Content)
            {
                throw new InvalidOperationException("Writer is in the wrong state to be writing text content");
            }

            XmlNode last = parent.LastChild;

            if (last == null || !(last is XmlText))
            {
                last = owner.CreateTextNode(text);
                parent.AppendChild(last);
            }
            else
            {
                XmlText t = last as XmlText;
                t.AppendData(text);
            }
        }