2016-03-17 46 views
1

所以,我有一個需要回調並執行它的操作。它看起來有點像這樣。有什麼我可以填入問號區域(或其他地方)以記錄進入APICall Func參數的參數的詳細信息?Func <T1,T2,....>參數的某些部分是否可以爲智能感知提供xml註釋?

/// <summary> 
/// Opens Authenticated session to servers using ClientSide SDK's, performs action, closes session 
/// </summary> 
/// <typeparam name="T">The object to be returned from the authenticated action</typeparam> 
/// <param name="credentials">Container for username, password</param> 
/// <param name="APICall">?????????????????</param> 
/// 
/// ????????????????????? 
/// ????????????????????? 
/// ????????????????????? 
///  
/// <returns>T</returns> 
private static T MakeAuthenticatedCall<T> (CredStorage Credentials, Func<string,T> APICALL) 
{ 
    AuthenticationManager.Login(Credentials); 
    T APIResult = APICall(AuthenticationManager.SessionID); 
    AuthenticationManager.LogOff(); 

    return APIResult; 
} 
+0

你是什麼意思?你不能把它放在之間嗎? –

+0

@AlexanderDerck我不這麼認爲。我正在描述「Func APICALL」的「字符串」和「T」部分,並沒有看到任何可以描述它們的明顯XML位。 – Sidney

回答

2

您可以定義自己的委託來執行此操作,而不是使用內置的Func<T,...>委託。

那麼您不僅可以給它XML文檔,還可以給參數提供一個更具描述性的名稱。

例如:

/// <summary>Makes an API call.</summary> 
/// <typeparam name="T">The type returned by the API call.</typeparam> 
/// <param name="param">The parameter passed to the API call.</param> 
/// <returns>The value returned by the API call.</returns> 

public delegate T ApiCall<T>(string param); 

那麼你會使用,而不是Func<string,T>在你的方法:

private static T MakeAuthenticatedCall<T>(CredStorage Credentials, ApiCall<T> APICALL) 
{ 

這無疑是做的更好的方法,雖然有犧牲花費額外的時間來定義一個特殊的代表。

相關問題