Class XPathDocumentExtensions
- Namespace
- Codebelt.Extensions.Swashbuckle.AspNetCore
- Assembly
- Codebelt.Extensions.Swashbuckle.AspNetCore.dll
Extension methods for the XPathDocument class.
public static class XPathDocumentExtensions
- Inheritance
-
XPathDocumentExtensions
Examples
Extend XML documentation loading with various discovery strategies:
using Codebelt.Extensions.Swashbuckle.AspNetCore;
using System.Collections.Generic;
using System.Xml.XPath;
namespace MySwaggerExample;
public class Program
{
public static void Main(string[] args)
{
var documents = new List<XPathDocument>();
// Load from a specific type's assembly
documents.AddByType<Program>();
// Load from a specific assembly
documents.AddByAssembly(typeof(Program).Assembly);
// Load from filename
documents.AddByFilename("Documentation.xml");
// Load from base directory
documents.AddFromBaseDirectory<Program>();
// Load from reference packs
documents.AddFromReferencePacks<Program>();
}
}
Methods
AddByAssembly(IList<XPathDocument>, Assembly)
Adds the specified assembly to the collection of documents.
public static IList<XPathDocument> AddByAssembly(this IList<XPathDocument> documents, Assembly assembly)
Parameters
documentsIList<XPathDocument>The collection of documents in XML format.
assemblyAssemblyThe assembly to locate XML documentation files by.
Returns
- IList<XPathDocument>
A reference to
documentsso that additional calls can be chained.
AddByFilename(IList<XPathDocument>, string)
Adds the specified path to the collection of documents.
public static IList<XPathDocument> AddByFilename(this IList<XPathDocument> documents, string path)
Parameters
documentsIList<XPathDocument>The collection of documents in XML format.
pathstringThe path to locate XML documentation files by.
Returns
- IList<XPathDocument>
A reference to
documentsso that additional calls can be chained.
AddByType(IList<XPathDocument>, Type)
Adds the specified type to the collection of documents.
public static IList<XPathDocument> AddByType(this IList<XPathDocument> documents, Type type)
Parameters
documentsIList<XPathDocument>The collection of documents in XML format.
typeTypeThe type to locate XML documentation files by.
Returns
- IList<XPathDocument>
A reference to
documentsso that additional calls can be chained.
AddByType<T>(IList<XPathDocument>)
Adds the assembly of T to the collection of documents.
public static IList<XPathDocument> AddByType<T>(this IList<XPathDocument> documents)
Parameters
documentsIList<XPathDocument>The collection of documents in XML format.
Returns
- IList<XPathDocument>
A reference to
documentsso that additional calls can be chained.
Type Parameters
TThe type to locate XML documentation files by.
AddFromBaseDirectory(IList<XPathDocument>, Type)
Adds XML documentation files from BaseDirectory that match the assembly of the specified type and its base types.
public static IList<XPathDocument> AddFromBaseDirectory(this IList<XPathDocument> documents, Type type)
Parameters
documentsIList<XPathDocument>The collection of documents in XML format.
typeTypeThe type whose assembly (and base type assemblies) is used to locate XML documentation files in the base directory.
Returns
- IList<XPathDocument>
A reference to
documentsso that additional calls can be chained.
AddFromBaseDirectory<T>(IList<XPathDocument>)
Adds XML documentation files from BaseDirectory that match the assembly of T and its base types.
public static IList<XPathDocument> AddFromBaseDirectory<T>(this IList<XPathDocument> documents)
Parameters
documentsIList<XPathDocument>The collection of documents in XML format.
Returns
- IList<XPathDocument>
A reference to
documentsso that additional calls can be chained.
Type Parameters
TThe type whose assembly (and base type assemblies) is used to locate XML documentation files in the base directory.
AddFromReferencePacks(IList<XPathDocument>, Type)
Adds XML documentation files from installed .NET reference packs that match the assembly of the specified type and its base types.
public static IList<XPathDocument> AddFromReferencePacks(this IList<XPathDocument> documents, Type type)
Parameters
documentsIList<XPathDocument>The collection of documents in XML format.
typeTypeThe type whose assembly (and base type assemblies) is used to locate XML documentation files in the .NET reference packs.
Returns
- IList<XPathDocument>
A reference to
documentsso that additional calls can be chained.
AddFromReferencePacks<T>(IList<XPathDocument>)
Adds XML documentation files from installed .NET reference packs that match the assembly of T and its base types.
public static IList<XPathDocument> AddFromReferencePacks<T>(this IList<XPathDocument> documents)
Parameters
documentsIList<XPathDocument>The collection of documents in XML format.
Returns
- IList<XPathDocument>
A reference to
documentsso that additional calls can be chained.
Type Parameters
TThe type whose assembly (and base type assemblies) is used to locate XML documentation files in the .NET reference packs.