/// <summary> /// Initializes a new instance of the <see cref="ReferenceSource"/> class /// with parameters copied from the specified instance of the /// <see cref="ReferenceSource"/> class, a copy constructor. /// </summary> /// <param name="source"> /// An instance of the <see cref="ReferenceSource"/> class from which the /// initialization parameters or values will be copied. /// </param> /// <exception cref="ArgumentNullException"> /// If the parameter <paramref name="source"/> is <see langword="null"/>. /// </exception> protected ReferenceSource(ReferenceSource source) : base(source) { _title = source._title; _tocContent = source._tocContent; _commentContent = source._commentContent; _typeFilters = source._typeFilters; _attributeFilters = source._attributeFilters; }
private void OnAttributeFilterItem(string keyword, XPathNavigator navigator) { ReferenceRootFilter attributeFilters = _group.Content.AttributeFilters; // If there is customization of the attribute filters, we use it... if (attributeFilters != null && attributeFilters.Count != 0) { XmlWriter writer = navigator.InsertAfter(); //<attributeFilter expose="true"> // <namespace name="System.Diagnostics" expose="false"> // <type name="ConditionalAttribute" expose="true" /> // </namespace> // <namespace name="System.Xml.Serialization" expose="false" /> //</attributeFilter> writer.WriteStartElement("attributeFilter"); writer.WriteAttributeString("expose", "true"); int itemNamespaces = attributeFilters.Count; for (int i = 0; i < itemNamespaces; i++) { ReferenceNamespaceFilter namespaceFilter = attributeFilters[i]; if (namespaceFilter == null) { continue; } namespaceFilter.WriteXml(writer); } writer.WriteEndElement(); writer.Close(); } else //...otherwise, we put in the default atttribute filters... { // Write the defaults... if (String.IsNullOrEmpty(_defaultAttrFile) == false && File.Exists(_defaultAttrFile)) { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; settings.IgnoreComments = false; settings.CloseInput = true; using (XmlReader xmlReader = XmlReader.Create( _defaultAttrFile, settings)) { if (xmlReader.IsStartElement("attributeFilter")) { navigator.InsertAfter(xmlReader); } } } } navigator.DeleteSelf(); }
/// <overloads> /// Initializes a new instance of the <see cref="ReferenceSource"/> class. /// </overloads> /// <summary> /// Initializes a new instance of the <see cref="ReferenceSource"/> class /// with the default parameters. /// </summary> protected ReferenceSource() { _title = String.Format("ReferenceSource{0:x}", Guid.NewGuid().ToString().GetHashCode()); _tocContent = new HierarchicalTocContent(); _commentContent = new CommentContent(); _typeFilters = new ReferenceRootFilter(false); _attributeFilters = new ReferenceRootFilter(true); }
public override ReferenceFilter Clone() { ReferenceRootFilter filter = new ReferenceRootFilter(this); if (_listNamespaces != null) { filter._listNamespaces = _listNamespaces.Clone(); } return(filter); }
public ReferenceContent() { _contentVersion = new Version(1, 0, 0, 0); _contentId = Guid.NewGuid().ToString(); _frameworkType = BuildFrameworkType.Framework20; _dependencies = new DependencyContent(); _tocContent = new HierarchicalTocContent(); _commentContent = new CommentContent(); _typeFilters = new ReferenceRootFilter(false); _attributeFilters = new ReferenceRootFilter(true); }
private void ReadFilters(XmlReader reader) { if (reader.IsEmptyElement) { return; } string startElement = reader.Name; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (String.Equals(reader.Name, ReferenceRootFilter.TagName, StringComparison.OrdinalIgnoreCase)) { string filterType = reader.GetAttribute("type"); if (String.Equals(filterType, "ApiFilter", StringComparison.OrdinalIgnoreCase)) { if (_typeFilters == null) { _typeFilters = new ReferenceRootFilter(false); } _typeFilters.ReadXml(reader); } else if (String.Equals(filterType, "AttributeFilter", StringComparison.OrdinalIgnoreCase)) { if (_attributeFilters == null) { _attributeFilters = new ReferenceRootFilter(true); } _attributeFilters.ReadXml(reader); } } } else if (reader.NodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, startElement, StringComparison.OrdinalIgnoreCase)) { break; } } } }
public ReferenceContent(ReferenceContent source) : base(source) { _isLoaded = source._isLoaded; _contentId = source._contentId; _contentVersion = source._contentVersion; _contentFile = source._contentFile; _contentDir = source._contentDir; _frameworkType = source._frameworkType; _tocContent = source._tocContent; _dependencies = source._dependencies; _commentContent = source._commentContent; _typeFilters = source._typeFilters; _attributeFilters = source._attributeFilters; }
private void OnApiFilterItem(string keyword, XPathNavigator navigator) { XmlWriter writer = navigator.InsertAfter(); // <apiFilter expose="true"> // <namespace name="System" expose="true"> // <type name="Object" expose="false"> // <member name="ToString" expose="true" /> // </type> // </namespace> // </apiFilter> writer.WriteStartElement("apiFilter"); writer.WriteAttributeString("expose", "true"); // Handle compiler and Generator outputs if (_compilerRootFilter != null && _compilerRootFilter.Count != 0) { int itemNamespaces = _compilerRootFilter.Count; for (int i = 0; i < itemNamespaces; i++) { ReferenceNamespaceFilter namespaceFilter = _compilerRootFilter[i]; namespaceFilter.WriteXml(writer); } } ReferenceRootFilter typeFilters = _group.Content.TypeFilters; if (typeFilters != null && typeFilters.Count != 0) { int itemNamespaces = typeFilters.Count; for (int i = 0; i < itemNamespaces; i++) { ReferenceNamespaceFilter namespaceFilter = typeFilters[i]; namespaceFilter.WriteXml(writer); } } writer.WriteEndElement(); writer.Close(); navigator.DeleteSelf(); }
public void Initialize(BuildContext context, string defaultAttrFile) { BuildExceptions.NotNull(context, "context"); base.Initialize(context.Logger); BuildSettings settings = context.Settings; if (settings == null) { this.IsInitialized = false; return; } _engineSettings = (ReferenceEngineSettings)settings.EngineSettings[ BuildEngineType.Reference]; Debug.Assert(_engineSettings != null, "The settings does not include the reference engine settings."); if (_engineSettings == null) { return; } _settings = settings; _context = context; _defaultAttrFile = defaultAttrFile; if (!String.IsNullOrEmpty(_defaultAttrFile) && File.Exists(_defaultAttrFile)) { string configDir = Path.GetDirectoryName(_defaultAttrFile); string apiFilterFile = Path.Combine(configDir, DefaultApiFilterFile); if (File.Exists(apiFilterFile)) { _compilerRootFilter = new ReferenceRootFilter(); _compilerRootFilter.Load(apiFilterFile); } } _assistComponents = null; if (_context.IsDirectSandcastle) { string sandcastleAssist = _settings.SandAssistDirectory; if (!String.IsNullOrEmpty(sandcastleAssist) && Directory.Exists(sandcastleAssist)) { // If the Sandcastle Assist component assembly is in the same // directory as the Sandcastle Helpers... string tempText = Path.Combine(sandcastleAssist, "Sandcastle.Reflection.dll"); if (File.Exists(tempText)) { _assistComponents = tempText; } } } // 1. The reference ... this.RegisterItem(KeywordNamer, new Action <string, XPathNavigator>(OnNamerItem)); // 2. The reference ... this.RegisterItem(KeywordAddins, new Action <string, XPathNavigator>(OnAddinsItem)); // 3. The reference ... this.RegisterItem(KeywordPlatform, new Action <string, XPathNavigator>(OnPlatformItem)); // 4. The reference ... this.RegisterItem(KeywordResolver, new Action <string, XPathNavigator>(OnResolverItem)); // 5. The reference ... this.RegisterItem(KeywordOptions, new Action <string, XPathNavigator>(OnOptionsItem)); // 6. The reference ... this.RegisterItem(KeywordApiFilter, new Action <string, XPathNavigator>(OnApiFilterItem)); // 7. The reference ... this.RegisterItem(KeywordAttributeFilter, new Action <string, XPathNavigator>(OnAttributeFilterItem)); this.IsInitialized = true; }
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); }
public ReferenceRootFilter(ReferenceRootFilter source) : base(source) { _isAttributes = source._isAttributes; _listNamespaces = source._listNamespaces; }