我创建了一个带有一些重载的函数。 现在我想为每个重载添加注释,但不是一次又一次地重复摘要内容。我只想要参数说明。
即
/// <summary>
/// Binds Control With DataTable/DataSet Passed as a Parameter. DataTable/Control Should not be NULL.
/// </summary>
/// <param name="lbx">DropDownList control</param>
/// <param name="dt">Object of DataTable from where value need be fetched.</param>
/// <param name="displayMember">Display Member for the list</param>
public static void Source(this DropDownList ddl, DataTable dt, string displayMember)
{
// do something.
}
/// <summary>
/// Binds Control With DataTable/DataSet Passed as a Parameter. DataTable/Control
/// </summary>
/// <param name="lbx">DropDownList control</param>
/// <param name="dt">Object of DataTable from where value need be fetched.</param>
/// <param name="displayMember">Display Member for the list</param>
/// <param name="_setDefaultItem">If True Sets the default value as -1 and corresponding string</param>
public static void Source(this DropDownList ddl, DataTable dt, string displayMember, bool _setDefaultItem)
{
//do something
}
这里我不想一次又一次地编写摘要部分,但只想在参数部分写注释。每次超载都应该可以看到休息。
有什么办法吗?
答案 0 :(得分:1)
您可以使用include标记来实现此目标。
创建一个xml文件,其中包含常用摘要,重载方法的参数说明。
并在每个重载方法中引用它,并在重载方法中单独添加特定于方法的参数列表注释。
/// <include file='common_tag.doc' path='MyDocs/MyMembers[@name="source"]/*' />
public static void Source(this DropDownList ddl, DataTable dt, string displayMember)
{
// do something.
}
/// <include file='common_tag.doc' path='MyDocs/MyMembers[@name="source"]/*' />
/// <param name="_setDefaultItem">If True Sets the default value as -1 and corresponding string</param>
public static void Source(this DropDownList ddl, DataTable dt, string displayMember, bool _setDefaultItem)
{
//do something
}
你的xml文件就像是
<MyDocs>
<MyMembers name="source">
<summary>
Binds Control With DataTable/DataSet Passed as a Parameter. DataTable/Control Should not be NULL
</summary>
<param>....</param>
</MyMembers>
</MyDocs>
我没有测试过这个......你可以试试这个