/// <summary> /// The creates the configuration information or settings required by the /// target component for the build process. /// </summary> /// <param name="group"> /// A build group, <see cref="BuildGroup"/>, representing the documentation /// target for configuration. /// </param> /// <param name="writer"> /// An <see cref="XmlWriter"/> object used to create one or more new /// child nodes at the end of the list of child nodes of the current node. /// </param> /// <returns> /// Returns <see langword="true"/> for a successful configuration; /// otherwise, it returns <see langword="false"/>. /// </returns> /// <remarks> /// The <see cref="XmlWriter"/> writer passed to this configuration object /// is created as a new child specifically for this object, and will not /// be passed onto other configuration objects. /// </remarks> public override bool Configure(BuildGroup group, XmlWriter writer) { BuildExceptions.NotNull(group, "group"); BuildExceptions.NotNull(writer, "writer"); if (!this.Enabled || !this.IsInitialized) { return(false); } IList <MediaContent> listMedia = group.MediaContents; // The HtmlHelp3 supports a different media link format... BuildFormatType formatType = _format.FormatType; writer.WriteComment(" Include the conceptual media links files "); //<targets input="..\TestLibrary\Media" baseOutput=".\Output" // outputPath="string('media')" link="../media" // map="..\TestLibrary\Media\MediaContent.xml" /> int contentCount = listMedia == null ? 0 : listMedia.Count; bool isConfigured = contentCount > 0; for (int i = 0; i < contentCount; i++) { MediaContent mediaContent = listMedia[i]; if (mediaContent == null || mediaContent.IsEmpty) { continue; } string mediaDir = Path.GetDirectoryName(mediaContent.ContentFile); if (String.IsNullOrEmpty(mediaDir)) { continue; } if (!mediaDir.EndsWith("\\")) { mediaDir += "\\"; } writer.WriteStartElement("targets"); writer.WriteAttributeString("input", mediaDir); writer.WriteAttributeString("baseOutput", mediaContent.OutputBase); writer.WriteAttributeString("outputPath", mediaContent.OutputPath); if (formatType == BuildFormatType.HtmlHelp3) { writer.WriteAttributeString("link", mediaContent.OutputLink); } else { writer.WriteAttributeString("link", "../" + mediaContent.OutputLink); } writer.WriteAttributeString("map", mediaContent.ContentFile); writer.WriteEndElement(); } string workingDir = _context.WorkingDirectory; BuildGroupContext groupContext = _context.GroupContexts[group.Id]; if (groupContext == null) { return(isConfigured); } string mediaFile = Path.Combine(workingDir, groupContext["$MediaFile"]); string mediaDirectory = Path.Combine(workingDir, groupContext["$DdueMedia"]); if (File.Exists(mediaFile) && (Directory.Exists(mediaDirectory) && !DirectoryUtils.IsDirectoryEmpty(mediaDirectory))) { isConfigured = true; string mediaDir = Path.GetDirectoryName(mediaFile); if (!mediaDir.EndsWith("\\")) { mediaDir += "\\"; } writer.WriteStartElement("targets"); writer.WriteAttributeString("input", mediaDir); writer.WriteAttributeString("baseOutput", @".\Output"); writer.WriteAttributeString("outputPath", "string('media')"); if (formatType == BuildFormatType.HtmlHelp3) { writer.WriteAttributeString("link", "media"); } else { writer.WriteAttributeString("link", "../" + "media"); } writer.WriteAttributeString("map", mediaFile); writer.WriteEndElement(); } return(isConfigured); }
/// <summary> /// The creates the configuration information or settings required by the /// target component for the build process. /// </summary> /// <param name="group"> /// A build group, <see cref="BuildGroup"/>, representing the documentation /// target for configuration. /// </param> /// <param name="writer"> /// An <see cref="XmlWriter"/> object used to create one or more new /// child nodes at the end of the list of child nodes of the current node. /// </param> /// <returns> /// Returns <see langword="true"/> for a successful configuration; /// otherwise, it returns <see langword="false"/>. /// </returns> /// <remarks> /// The <see cref="XmlWriter"/> writer passed to this configuration object /// may be passed on to other configuration objects, so do not close or /// dispose it. /// </remarks> public override bool Configure(BuildGroup group, XmlWriter writer) { BuildExceptions.NotNull(group, "group"); BuildExceptions.NotNull(writer, "writer"); if (!this.Enabled || !this.IsInitialized) { return(false); } IList <MediaContent> listMedia = group.MediaContents; if (listMedia == null || listMedia.Count == 0) { return(false); } bool useInclude = false; FormatMhv mhvFormat = _settings.Formats[BuildFormatType.HtmlHelp3] as FormatMhv; if (mhvFormat != null && mhvFormat.Enabled) { useInclude = true; } writer.WriteStartElement("options"); // start: options writer.WriteAttributeString("useInclude", useInclude.ToString()); writer.WriteEndElement(); // end: options // The HtmlHelp3 supports a different media link format... BuildFormatType formatType = BuildFormatType.None; int contentCount = listMedia.Count; for (int i = 0; i < contentCount; i++) { MediaContent mediaContent = listMedia[i]; if (mediaContent == null || mediaContent.IsEmpty) { continue; } string mediaDir = Path.GetDirectoryName(mediaContent.ContentFile); if (String.IsNullOrEmpty(mediaDir)) { continue; } if (!mediaDir.EndsWith("\\")) { mediaDir += "\\"; } writer.WriteStartElement("targets"); writer.WriteAttributeString("input", mediaDir); writer.WriteAttributeString("baseOutput", mediaContent.OutputBase); writer.WriteAttributeString("outputPath", mediaContent.OutputPath); if (formatType == BuildFormatType.HtmlHelp3) { writer.WriteAttributeString("link", mediaContent.OutputLink); } else { writer.WriteAttributeString("link", "../" + mediaContent.OutputLink); } writer.WriteAttributeString("map", mediaContent.ContentFile); writer.WriteEndElement(); } return(true); }