Table of Contents

XPathDocumentExtensions Class

Definition

Namespace
Codebelt.Extensions.Swashbuckle.AspNetCore
Assemblies
Codebelt.Extensions.Swashbuckle.AspNetCore.dll
Source
src/Codebelt.Extensions.Swashbuckle.AspNetCore/XPathDocumentExtensions.cs

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

Name Description
AddByAssembly(IList<XPathDocument>, Assembly)

Adds the specified assembly to the collection of documents.

AddByFilename(IList<XPathDocument>, string)

Adds the specified path to the collection of documents.

AddByType(IList<XPathDocument>, Type)

Adds the specified type to the collection of documents.

AddByType<T>(IList<XPathDocument>)

Adds the assembly of T to the collection of documents.

AddFromBaseDirectory(IList<XPathDocument>, Type)

Adds XML documentation files from BaseDirectory that match the assembly of the specified type and its base types.

AddFromBaseDirectory<T>(IList<XPathDocument>)

Adds XML documentation files from BaseDirectory that match the assembly of T and its base types.

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.

AddFromReferencePacks<T>(IList<XPathDocument>)

Adds XML documentation files from installed .NET reference packs that match the assembly of T and its base types.