2012-03-12 51 views
0

我有一個非常簡單的問題,您將如何用xmldoc記錄一個方法或具有通用Action或Func返回類型的屬性。 例如:如何在方法或屬性中記錄返回類型爲通用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; } 

這是哪種情況下的最佳做法?

回答

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); 
+0

這是一個很好的建議!但問題不在於是使用Action還是Func作爲屬性或方法的返回類型,而不是如何記錄它。 – 2012-03-22 11:28:53

+0

@Shurup,我的觀點是沒有「乾淨」的方式來記錄Action或Func的參數;如果您需要這樣做,請創建一個可以記錄參數的特定代理。 – 2012-03-22 13:14:05

相關問題