Rem*_*emy 7 asp.net-web-api asp.net-web-api-helppages
在我的源代码文档中,我经常使用:
Get a <see cref="Quote"/> for the specified <see cref="apiOrder"/> object.
Run Code Online (Sandbox Code Playgroud)
这很好地转换为XmlDocument.xml中的下面的字符串,其中包含已编译的web api帮助页面.
Get a <see cref="T:Supertext.API.POCO.Quote"/> for the specified <see cref="!:apiOrder"/> object.
Run Code Online (Sandbox Code Playgroud)
但由于某些原因,所有这些引用都没有显示出来.我们得到的是:
Get a for the specified object
Run Code Online (Sandbox Code Playgroud)
我们找到了一些来源,但似乎没有任何效果.没有帮助:
Web Api帮助页面 - 不要在xml文档中转义html
过时的:http:
//thesoftwaredudeblog.wordpress.com/2014/01/04/using-microsoft-asp-net-web-api-2-help-page-part-2/
有任何想法吗?
小智 4
In the WebAPI 2 Help, there is a class called, XmlDocumentationProvider. In this class there is a method named, GetTagValue which handles the Summary and Returns tags. There is also a method named GetDocumentation (there are multiples, but it is the one with the HttpParameterDescriptor parameter) which handles the Param tags.
I wrote a function that uses a RegEx to find all "See Cref"s and replace them with the last object name found.
The RegEx:
private static Regex SeeCodeReferenceRegEx = new Regex("<see cref=\\\"\\w:([\\w]+\\.)*(\\w+)\\\" */>", RegexOptions.Compiled);
Run Code Online (Sandbox Code Playgroud)
The function:
private static string CleanValue(string value)
{
value = value.Trim();
var matches = SeeCodeReferenceRegEx.Matches(value);
foreach (Match match in matches)
value = value.Replace(match.Groups[0].Value, match.Groups[2].Value);
return value;
}
Run Code Online (Sandbox Code Playgroud)
In GetTagValue, replace:
return node.Value.Trim();
Run Code Online (Sandbox Code Playgroud)
with:
return CleanValue(node.InnerXml);
Run Code Online (Sandbox Code Playgroud)
In GetDocumentation replace:
return parameterNode.Value.Trim();
Run Code Online (Sandbox Code Playgroud)
with:
return CleanValue(parameterNode.InnerXml);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
714 次 |
| 最近记录: |