コード例 #1
0
 protected override void OnWriteContents(XmlWriter writer)
 {
     if (_dependencies != null)
     {
         writer.WriteStartElement("content");
         writer.WriteAttributeString("type", "Dependencies");
         _dependencies.WriteXml(writer);
         writer.WriteEndElement();
     }
 }
コード例 #2
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");

            writer.WriteStartElement(TagName);
            writer.WriteAttributeString("version", _contentVersion.ToString(2));

            // 1. The content directory, if not the same as the content file.
            writer.WriteComment(
                " 1. The content directory, if not the same as the content file. ");
            writer.WriteStartElement("location"); // start - location
            if (_contentDir != null &&
                !_contentDir.IsDirectoryOf(_contentFile))
            {
                _contentDir.WriteXml(writer);
            }
            writer.WriteEndElement();             // end - location

            // 2. The general content settings
            writer.WriteComment(" 2. The general content settings ");
            writer.WriteStartElement("propertyGroup");  // start - propertyGroup
            writer.WriteAttributeString("name", "General");

            writer.WritePropertyElement("Id", _contentId);
            writer.WritePropertyElement("FrameworkType", _frameworkType.ToString());

            writer.WriteEndElement();                   // end - propertyGroup

            // 3. The reference items defining the API content
            writer.WriteComment(" 3. The reference items defining the API content ");
            writer.WriteStartElement("referenceItems");  // start - referenceItems
            for (int i = 0; i < this.Count; i++)
            {
                ReferenceItem item = this[i];
                if (item != null && !item.IsEmpty)
                {
                    item.WriteXml(writer);
                }
            }
            writer.WriteEndElement();                    // end - referenceItems

            // 4. The various contents required for documentation
            writer.WriteComment(" 4. The various contents required for documentation ");
            writer.WriteStartElement("contents");  // start - contents

            if (_commentContent != null)
            {
                BuildFilePath filePath = _commentContent.ContentFile;
                writer.WriteStartElement("content");
                writer.WriteAttributeString("type", "Comments");
                if (filePath != null && filePath.IsValid)
                {
                    BuildPathResolver resolver = BuildPathResolver.Resolver;
                    Debug.Assert(resolver != null && resolver.Id == _contentId);

                    writer.WriteAttributeString("source",
                                                resolver.ResolveRelative(filePath));
                    _commentContent.Save();
                }
                else
                {
                    _commentContent.WriteXml(writer);
                }
                writer.WriteEndElement();
            }
            if (_dependencies != null)
            {
                writer.WriteStartElement("content");
                writer.WriteAttributeString("type", "Dependencies");
                _dependencies.WriteXml(writer);
                writer.WriteEndElement();
            }
            if (_tocContent != null)
            {
                writer.WriteStartElement("content");
                writer.WriteAttributeString("type", "HierarchicalToc");
                _tocContent.WriteXml(writer);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();              // end - contents

            // 5. The API/attribute filters associated with the documentations
            writer.WriteComment(" 5. The API/attribute filters associated with the documentations ");
            writer.WriteStartElement("filters");  // start - filters
            if (_typeFilters != null)
            {
                _typeFilters.WriteXml(writer);
            }
            if (_attributeFilters != null)
            {
                _attributeFilters.WriteXml(writer);
            }
            writer.WriteEndElement();             // end - filters

            writer.WriteEndElement();
        }