Exemplo n.º 1
0
        /// <summary>
        /// This writes the current state or attributes of this object,
        /// in the <c>XML</c> format, to the media or storage accessible by the given writer.
        /// </summary>
        /// <param name="writer">
        /// The <c>XML</c> writer with which the <c>XML</c> format of this object's state
        /// is written.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="reader"/> is <see langword="null"/>.
        /// </exception>
        public override void WriteXml(XmlWriter writer)
        {
            BuildExceptions.NotNull(writer, "writer");

            if (this.IsEmpty)
            {
                return;
            }

            writer.WriteStartElement(TagName);  // start - item
            writer.WriteAttributeString("name", _name);
            writer.WriteAttributeString("id", _tocId);

            writer.WriteStartElement("source"); // start - source
            writer.WriteAttributeString("id", _sourceId);
            writer.WriteAttributeString("type", _sourceType.ToString());
            writer.WriteAttributeString("recursive", _isRecursive.ToString());
            writer.WriteEndElement();           // end - source

            if (_listItems != null && _listItems.Count != 0)
            {
                for (int i = 0; i < _listItems.Count; i++)
                {
                    _listItems[i].WriteXml(writer);
                }
            }

            writer.WriteEndElement();           // end - item
        }