asp.net web api - 使用多个Xml文件显示帮助文档
来源:互联网 发布:kdj选股软件 编辑:程序博客网 时间:2024/06/06 03:12
在目录 ~/Areas/HelpPage/ 下新增一个名为 MultiXmlDocumentationProvider.cs 的类。
using System; using System.Linq; using System.Reflection; using System.Web.Http.Controllers; using System.Web.Http.Description; using project_namespace.Areas.HelpPage.ModelDescriptions; namespace Xlobo.RechargeService.Areas.HelpPage { /// <summary>A custom <see cref="IDocumentationProvider"/> that reads the API documentation from a collection of XML documentation files.</summary> public class MultiXmlDocumentationProvider : IDocumentationProvider, IModelDocumentationProvider { /********* ** Properties *********/ /// <summary>The internal documentation providers for specific files.</summary> private readonly XmlDocumentationProvider[] Providers; /********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="paths">The physical paths to the XML documents.</param> public MultiXmlDocumentationProvider(params string[] paths) { this.Providers = paths.Select(p => new XmlDocumentationProvider(p)).ToArray(); } /// <summary>Gets the documentation for a subject.</summary> /// <param name="subject">The subject to document.</param> public string GetDocumentation(MemberInfo subject) { return this.GetFirstMatch(p => p.GetDocumentation(subject)); } /// <summary>Gets the documentation for a subject.</summary> /// <param name="subject">The subject to document.</param> public string GetDocumentation(Type subject) { return this.GetFirstMatch(p => p.GetDocumentation(subject)); } /// <summary>Gets the documentation for a subject.</summary> /// <param name="subject">The subject to document.</param> public string GetDocumentation(HttpControllerDescriptor subject) { return this.GetFirstMatch(p => p.GetDocumentation(subject)); } /// <summary>Gets the documentation for a subject.</summary> /// <param name="subject">The subject to document.</param> public string GetDocumentation(HttpActionDescriptor subject) { return this.GetFirstMatch(p => p.GetDocumentation(subject)); } /// <summary>Gets the documentation for a subject.</summary> /// <param name="subject">The subject to document.</param> public string GetDocumentation(HttpParameterDescriptor subject) { return this.GetFirstMatch(p => p.GetDocumentation(subject)); } /// <summary>Gets the documentation for a subject.</summary> /// <param name="subject">The subject to document.</param> public string GetResponseDocumentation(HttpActionDescriptor subject) { return this.GetFirstMatch(p => p.GetDocumentation(subject)); } /********* ** Private methods *********/ /// <summary>Get the first valid result from the collection of XML documentation providers.</summary> /// <param name="expr">The method to invoke.</param> private string GetFirstMatch(Func<XmlDocumentationProvider, string> expr) { return this.Providers .Select(expr) .FirstOrDefault(p => !String.IsNullOrWhiteSpace(p)); } } }
替换掉原始 ~/Areas/HelpPage/HelpPageConfig.cs 内的配置。
//config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml"))); config.SetDocumentationProvider(new MultiXmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml"), HttpContext.Current.Server.MapPath("~/App_Data/another.XmlDocument.xml")));
0 0
- asp.net web api - 使用多个Xml文件显示帮助文档
- asp.net web api帮助文档的说明
- ASP.NET Web API 使用Swagger生成在线帮助测试文档
- asp.net web api帮助生成插件
- ASP.NET Core Web API 描述文档-使用Swagger
- 使用xml文件生成在线帮助文档
- ASP.NET Web API 帮助界面测试+接口注释
- 在ASP.NET Core Web API上使用Swagger提供API文档
- 在ASP.NET Core Web API上使用Swagger提供API文档
- 支持多个版本的ASP.NET Core Web API
- 【ASP.NET Web API教程】6.2 ASP.NET Web API中的JSON和XML序列化
- ASP.NET Web API使用示例
- asp.net之使用web API
- ASP.NET Web API使用示例
- 关于ASP.NET Web Api的HelpPage文档注释问题
- 关于ASP.NET Web Api的HelpPage文档注释问题
- 关于ASP.NET Web Api的HelpPage文档注释问题
- 关于ASP.NET Web Api的HelpPage文档注释问题
- PHP关于VC11,VC9,VC6以及Thread Safe和Non Thread Safe版本选择的问题
- git撤销本地修改与回退版本
- 偏函数
- Ubuntu下切换用户免密与smb挂载开启
- Elasticsearch安装ik分词
- asp.net web api - 使用多个Xml文件显示帮助文档
- 多线程Atomic和ThreadLocal
- bat批处理svn
- Map集合中value()方法与keySet()、entrySet()区别
- 远程桌面的问题?
- mysql if函数 concat 函数 和substring 函数
- AppDelegate中几个常用的回调调用时机
- Nginx+php+fastcgi在win7下的配置
- 洞悉安卓应用的电池使用状况