如何在方法或属性中记录类型参数,返回类型为通用Action或Func

时间:2012-03-12 22:58:05

标签: .net generics type-parameter xml-documentation

我有一个非常简单的问题,你如何用xmldoc记录一个方法或一个返回类型为泛型Action或Func的属性。 例如:

/// <summary>
/// Gets or sets the print method. Parameters: file, printer name???
/// </summary> 
/// <value>
/// The print method.
/// </value>
public Action<string, string> PrintMethod { get; set; }

这种情况下的最佳做法是什么?

1 个答案:

答案 0 :(得分:0)

如果您需要记录此操作的参数,请不要使用Action<string, string>:改为创建自定义委托,并记录委托的参数。

/// <summary>
/// Gets or sets the print method.
/// </summary> 
/// <value>
/// The print method.
/// </value>
public FilePrintAction PrintMethod { get; set; }

/// <summary>
/// Represents a method for printing a file to a printer
/// </summary> 
/// <parameter name="file">Path of the file to print</parameter>
/// <parameter name="printerName">Name of the printer</parameter>
public delegate void FilePrintAction(string file, string printerName);