我正在尝试将HTML(特别是href)嵌入到DescriptionAttribute中,以将自动生成的WCF帮助文档中的链接添加到更详细的SandCastle生成的页面中,该页面描述了所涉及的数据结构。有点像:
[Description(
"Creates jobs. A detailed description of the Jobs data structure can " +
"be found <a href=\"http://www.example.com/api/docs/jobs\">here.</a>")]
[WebInvoke(UriTemplate = "Jobs", Method = "POST")]
public Jobs CreateJobs(Jobs jobs)
{
...
}
这会在生成的文档中生成以下HTML,我的嵌入式HTML编码为字符实体:
<td>Creates jobs. A detailed description of the Jobs data structure can be found <a href="http://www.example.com/api/docs/jobs\">here.</a></td>
将完全呈现如下:
创造就业机会。一个 可以找到Jobs数据结构的详细描述&lt; a HREF = “HTTP://www.example.com/api/docs/jobs \” &gt;此处&LT; / A&GT;
但是我希望它像这样呈现:
创造就业机会。 Jobs数据结构的详细描述 可以找到here.
我想知道我是否可以覆盖Description属性来删除字符实体,所以我尝试了这个:
class HtmlDescriptionAttribute : System.ComponentModel.DescriptionAttribute
{
public override string Description
{
get
{
string description = base.Description;
//
// Remove encoding from description here
//
return description;
}
}
public HtmlDescriptionAttribute() : base() { }
public HtmlDescriptionAttribute(string description) : base(description) { }
}
但是在重写的属性中加入一个断点,我发现在这个阶段它还没有被编码。因此,无论调用此属性,都可能会添加编码。
有没有人知道是否/如何做到这一点?
谢谢!