<include>(C# 编程指南)
更新:2007 年 11 月
<include file='filename' path='tagpath[@name="id"]' />
参数
filename
包含文档的文件名。该文件名可用路径加以限定。将 filename 括在单引号 (' ') 中。tagpath
filename 中指向标记 name 的标记路径。将此路径括在单引号中 (' ')。name
注释前边的标记中的名称说明符;name 具有一个 id。id
位于注释之前的标记的 ID。将此 ID 括在双引号中 (" ")。
备注
<include> 标记使您得以引用描述源代码中类型和成员的另一文件中的注释。这是除了将文档注释直接置于源代码文件中之外的另一种可选方法。
<include> 标记使用 XML XPath 语法。有关自定义 <include> 使用的方法,请参见 XPath 文档。
示例
以下是一个多文件示例。第一个文件使用 <include> ,如下所列:
// compile with: /doc:DocFileName.xml
/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test"]/*' />
class Test
{
static void Main()
{
}
}
/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test2"]/*' />
class Test2
{
public void Test()
{
}
}
第二个文件 xml_include_tag.doc 包含下列文档注释:
<MyDocs>
<MyMembers name="test">
<summary>
The summary for this type.
</summary>
</MyMembers>
<MyMembers name="test2">
<summary>
The summary for this other type.
</summary>
</MyMembers>
</MyDocs>
程序输出
<?xml version="1.0"?>
<doc>
<assembly>
<name>xml_include_tag</name>
</assembly>
<members>
<member name="T:Test">
<summary>
The summary for this type.
</summary>
</member>
<member name="T:Test2">
<summary>
The summary for this other type.
</summary>
</member>
</members>
</doc>