private Func<PutPullFileServiceResult> PutPullRetry(PutPullFileServiceRequest request)
{
PutPullFileServiceResult result = new PutPullFileServiceResult();
return () => ///// 1
{
result = ServiceClient.PutPullFile(request);
return result;
};
}
上面方法位置1处,return后的 "() =>" 是上面意思,作用是什么?
public static void Retry<TException>(Action action, int sleepTime) //// 5
where TException : Exception //// 2
{
Retry<int, TException>(() => //// 3
{
action(); //// 4
return -1;
}, sleepTime);
}
上面方法2处 "where TException" 中的 "where" 是什么意思,作用是什么?
还有3处什么意思?
4处在类中并没有action();方法, 当我跳转到定义位置时就自动跑到5处action参数上,这又是什么意思?
以上问题希望各位高手指点下,先谢谢了。。。有写的不清楚的地方指出详谈啊,分数可以再加。
着急着急,。。。
第二个方法所在类的详细内容:
public static class RetryHandler
{
public static void Retry(Action action)
{
Retry<Exception>(action);
}
public static void Retry<TException>(Action action)
where TException : Exception
{
Retry<TException>(action, 0);
}
public static void Retry(Action action, int sleepTime)
{
Retry<Exception>(action, sleepTime);
}
public static void Retry<TException>(Action action, int sleepTime)
where TException : Exception
{
Retry<int, TException>(() =>
{
action();
return -1;
}, sleepTime);
}
public static TResult Retry<TResult, TException>(Func<TResult> action, int sleepTime)
where TException : Exception
{
//// 详细的业务处理。。。
}
}
=>è¿ä¸ªç¬¦å·çææä¹å°±æ¯è¯´ï¼ç¬¬ä¸ä¸ªæ¹æ³ä¸returnçæ¯
result = ServiceClient.PutPullFile(request);
return result;
è¿ä¸ªreturnçç»æã
é£ä»ä¸ºä»ä¹=>符å·åå 个ï¼ï¼åï¼è¿æ¯è¯´å°±æ¯è¿ç§ç¨æ³ï¼
åæ æ示..æè®°å¾çåæ³æ¯ ({})...ä»è¿ä¸ªçææå ¶å®æ¯å¿åå½æ°å¦
追é®é£ç¬¬äºä¸ªé®é¢è½è¯¦ç»è¯´ä¸åï¼whereæ¯è§£éè¯å¥ï¼æ¯ä»ä¹ææï¼ã
追çä¾å¦ public T GetString (string a) where T:String
é£ä¹è¿ä¸ªTåªè½æ¯STRINGç±»åç.æè
说STRINGæè
STRINGçåç±»
å¦ææåæWhere T:Int
å°±æäºINTæè
INTçåç±»
å¦ææ¯Where T:Type
è¿ä¸ªæææ¯æ³åäº..ä¸è¿åæ³å¿è®°äº- -æç ..åä¸çå°±çå°ä½ 追é®äº..