Preface:
You have to know the Helppageconfig file, do not know that you do not need this now, so you do not have to look at the following, and so on to see no hurry. Of course, if you know this, you don't have to look at it, because you will.
method One:
new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/Documentation.xml"))
替换成
new XmlDocumentationProvider("PluginsFolder/*.xml")
改ctor函数让他支持多个XML文档
usingSystem.Xml.Linq;usingSystem.Xml.XPath; XDocument Finaldoc =NULL;foreach(stringFileinchDirectory.GetFiles (@ "Pluginsfolder", "*.xml")) {if(Finaldoc = =NULL) {Finaldoc = Xdocument.load (File.openread (File)); }Else{XDocument xdocadditional = Xdocument.load (File.openread (File)); FinalDoc.Root.XPathSelectElement ("/doc/members") . ADD (XdocAdditional.Root.XPathSelectElement ("/doc/members"). Elements ()); }}//Supply the Navigator that rest of the Xmldocumentationprovider code looks for_documentnavigator = Finaldoc.createnavigator ();
Method Two: Customizing a xmldocumentationprovider that supports loading XML documents from a directory
PublicMultixmldocumentationprovider (stringXmldocfilespath) {XDocument Finaldoc =NULL;foreach(stringFileinchDirectory.GetFiles (Xmldocfilespath, "*.xml")) {using(var fileStream = File.openread (File)) {if(Finaldoc = =NULL) {Finaldoc = Xdocument.load (FileStream); }Else{XDocument xdocadditional = xdocument.load (FileStream); FinalDoc.Root.XPathSelectElement ("/doc/members") . ADD (XdocAdditional.Root.XPathSelectElement ("/doc/members"). Elements ()); } } }//Supply the Navigator that rest of the Xmldocumentationprovider code looks for_documentnavigator = Finaldoc.createnavigator ();}
How to use:
config.SetDocumentationProvider(new MultiXmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/")));
PublicXmldocumentationprovider (ienumerable<string> documentpaths) {if(Documentpaths.isnullorempty ()) {Throw NewArgumentNullException (nameof (documentpaths)); } XDocument fulldocument =NULL;foreach(Var documentpathinchDocumentpaths) {if(Documentpath = =NULL) {Throw NewArgumentNullException (nameof (documentpath)); }if(Fulldocument = =NULL) {using(var stream = File.openread (documentpath)) {fulldocument = Xdocument.load (stream); } }Else{using(var stream = File.openread (documentpath)) {var additionaldocument = xdocument.load (stream); Fulldocument?. Root?. Xpathselectelement ("/doc/members"). Add (additionaldocument?. Root?. Xpathselectelement ("/doc/members"). Elements ()); }}} _documentnavigator = Fulldocument?. CreateNavigator ();}
How to use:
New []{ HttpContext.Current.Server.MapPath ("~/bin/path.to.firstnamespace.xml"), HttpContext.Current.Server.MapPath ("~/bin/path.to.othernamespace.xmlNew Xmldocumentationprovider (xmlpaths); config. Setdocumentationprovider (Documentationprovider);
Related articles:
Web Api Help Page XML comments from than 1 files (http://stackoverflow.com/questions/22165724/ web-api-help-page-xml-comments-from-more-than-1-files/22169357#22169357)
Address of this article:
Reading data from multiple XML documents for displaying the WEBAPI Help document (http://www.cnblogs.com/shiningrise/p/XmlDocumentationProvider.html)
Reading data from multiple XML documents for displaying WEBAPI help documents