protected override void OnReadContentXml(XmlReader reader) { if (String.Equals(reader.Name, "content", StringComparison.OrdinalIgnoreCase) && String.Equals( reader.GetAttribute("type"), "Reference", StringComparison.OrdinalIgnoreCase)) { if (_topicContent == null) { _topicContent = new ReferenceContent(); } if (reader.IsEmptyElement) { string sourceFile = reader.GetAttribute("source"); if (!String.IsNullOrEmpty(sourceFile)) { _topicContent.ContentFile = new BuildFilePath(sourceFile); _topicContent.Load(); } } else { if (reader.ReadToDescendant(ReferenceContent.TagName)) { _topicContent.ReadXml(reader); } } } }
/// <summary> /// This reads and sets its state or attributes stored in a <c>XML</c> format /// with the given reader. /// </summary> /// <param name="reader"> /// The reader with which the <c>XML</c> attributes of this object are accessed. /// </param> /// <exception cref="ArgumentNullException"> /// If the <paramref name="reader"/> is <see langword="null"/>. /// </exception> public override void ReadXml(XmlReader reader) { BuildExceptions.NotNull(reader, "reader"); Debug.Assert(reader.NodeType == XmlNodeType.Element); if (reader.NodeType != XmlNodeType.Element) { return; } if (!String.Equals(reader.Name, TagName, StringComparison.OrdinalIgnoreCase)) { Debug.Assert(false, String.Format( "The element name '{0}' does not match the expected '{1}'.", reader.Name, TagName)); return; } if (reader.IsEmptyElement) { return; } while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (String.Equals(reader.Name, "propertyGroup", StringComparison.OrdinalIgnoreCase)) { this.ReadPropertyGroup(reader); } else if (String.Equals(reader.Name, "content", StringComparison.OrdinalIgnoreCase)) { if (_content == null) { _content = new ReferenceContent(); } if (reader.IsEmptyElement) { string sourceFile = reader.GetAttribute("source"); if (!String.IsNullOrEmpty(sourceFile)) { _content.ContentFile = new BuildFilePath(sourceFile); _content.Load(); } } else { if (reader.ReadToDescendant(ReferenceContent.TagName)) { _content.ReadXml(reader); } } } else if (String.Equals(reader.Name, "contents", StringComparison.OrdinalIgnoreCase)) { this.ReadContents(reader); } else if (String.Equals(reader.Name, "filters", StringComparison.OrdinalIgnoreCase)) { this.ReadFilters(reader); } } else if (reader.NodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, TagName, StringComparison.OrdinalIgnoreCase)) { break; } } } }
public override ReferenceContent Create(BuildGroupContext groupContext) { BuildExceptions.NotNull(groupContext, "groupContext"); BuildContext context = groupContext.Context; BuildLogger logger = null; if (context != null) { logger = context.Logger; } if (!this.IsInitialized) { throw new BuildException(String.Format( "The content source '{0}' is not yet initialized.", this.Title)); } if (!this.IsValid) { if (logger != null) { logger.WriteLine(String.Format( "The content group source '{0}' is invalid.", this.Title), BuildLoggerLevel.Warn); } return(null); } ReferenceContent content = new ReferenceContent(_sourcePath); content.Load(); CommentContent sourceComments = this.Comments; if (_overrideComments == null) { // Provide other user-supplied information to the content... if (sourceComments != null && !sourceComments.IsEmpty) { // Merge the comments, overriding any existing... CommentContent importComments = content.Comments; if (importComments == null || importComments.IsEmpty) { content.Comments = sourceComments; } else { for (int i = 0; i < sourceComments.Count; i++) { CommentItem sourceItem = sourceComments[i]; if (!sourceItem.IsEmpty) { importComments.Add(sourceItem); } } } } } else if (_overrideComments.Value) { content.Comments = sourceComments; } HierarchicalTocContent hierarchicalToc = this.HierarchicalToc; if (_overrideHierarchicalToc == null) { if (hierarchicalToc != null && !hierarchicalToc.IsEmpty) { content.HierarchicalToc = hierarchicalToc; } } else if (_overrideHierarchicalToc.Value) { content.HierarchicalToc = hierarchicalToc; } ReferenceRootFilter typeFilters = this.TypeFilters; ReferenceRootFilter attributeFilters = this.AttributeFilters; if (_overrideFilters == null) { if (typeFilters != null && !typeFilters.IsEmpty) { content.TypeFilters = typeFilters; } if (attributeFilters != null && !attributeFilters.IsEmpty) { content.AttributeFilters = attributeFilters; } } else if (_overrideFilters.Value) { content.TypeFilters = typeFilters; content.AttributeFilters = attributeFilters; } return(content); }