コード例 #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");

            writer.WriteStartElement(TagName);  // start - TagName
            writer.WriteAttributeString("version", _version.ToString(2));

            //  1. Documentation: Settings of the documentation
            writer.WriteComment(" 1. Documentation: Settings of the documentation ");
            if (_settings != null)
            {
                _settings.WriteXml(writer);
            }

            // 2. Documentation: Group sources of the documentation
            writer.WriteComment(" 2. Documentation: Group sources of the documentation ");
            writer.WriteStartElement("documentSources"); // start - documentSources
            if (_listSources != null && _listSources.Count != 0)
            {
                for (int i = 0; i < _listSources.Count; i++)
                {
                    _listSources[i].WriteXml(writer);
                }
            }
            writer.WriteEndElement();                    // end - documentSources

            // 3. Documentation: Groups of the documentation
            writer.WriteComment(" 3. Documentation: Groups of the documentation ");
            writer.WriteStartElement("documentGroups"); // start - documentGroups
            if (_listGroups != null && _listGroups.Count != 0)
            {
                BuildPathResolver resolver = BuildPathResolver.Resolver;
                Debug.Assert(resolver != null && resolver.Id == _documentId);

                for (int i = 0; i < _listGroups.Count; i++)
                {
                    BuildGroup group = _listGroups[i];

                    BuildFilePath filePath = group.ContentFile;
                    if (filePath != null && filePath.IsValid)
                    {
                        writer.WriteStartElement(BuildGroup.TagName);
                        writer.WriteAttributeString("type", group.GroupType.ToString());
                        writer.WriteAttributeString("source", resolver.ResolveRelative(filePath));
                        writer.WriteEndElement();

                        group.Save();
                    }
                    else
                    {
                        group.WriteXml(writer);
                    }
                }
            }
            writer.WriteEndElement();           // end - documentGroups

            writer.WriteEndElement();           // end - TagName
        }
コード例 #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);
            string hintPath = this.HintPath;

            if (String.IsNullOrEmpty(hintPath))
            {
                BuildPathResolver resolver = BuildPathResolver.Resolver;
                writer.WriteAttributeString("value",
                                            resolver.ResolveRelative(this.Path));
            }
            else
            {
                writer.WriteAttributeString("value", this.Name);
                writer.WriteString(hintPath);
            }
            writer.WriteEndElement();
        }