Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
namespace WebApi.Areas.HelpPage
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Web.Http.Controllers;
using System.Web.Http.Description;
using System.Xml.XPath;
using WebApi.Areas.HelpPage.ModelDescriptions;
/// <summary>
/// A custom <see cref="IDocumentationProvider"/> that reads the API documentation from an XML documentation file.
/// </summary>
public class XmlDocumentationProvider : IDocumentationProvider, IModelDocumentationProvider
{
private IList<XPathNavigator> _documentNavigator = new List<XPathNavigator>();
// CÓDIGO ADICIONAL DE LA APLICACIÓN
/// <summary>
/// Initializes a new instance of the <see cref="XmlDocumentationProvider"/> class.
/// </summary>
/// <param name="documentPath">The physical path to XML document.</param>
public XmlDocumentationProvider(string documentPath)
{
if (documentPath == null)
{
throw new ArgumentNullException("documentPath");
}
var files = System.IO.Directory.GetFiles(documentPath, "*.xml");
foreach (var file in files)
{
XPathDocument xpath = new XPathDocument(file);
_documentNavigator.Add(xpath.CreateNavigator());
}
}
private XPathNavigator SelectSingleNode(string selectExpression)
{
foreach (var navigator in _documentNavigator)
{
var propertyNode = navigator.SelectSingleNode(selectExpression);
if (propertyNode != null)
return propertyNode;
}
return null;
}
// CÓDIGO ADICIONAL DE LA APLICACIÓN
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.