I'm trying to get the method name of a function passed into an object using a .Net closure like this:
Method Signature
public IEnumerable<T> GetData<T>(Func<IEnumerable<T>> WebServiceCallback)
where T : class
{
// either gets me '<LoadData>b__3'
var a = nrdsWebServiceCallback.Method.Name;
var b = nrdsWebServiceCallback.GetInvocationList();
return WebServiceCallback();
}
I'm calling it like this:
SessionStateService.Labs = CacheManager.GetData(() =>
WCFService.GetLabs(SessionStateService.var1, SessionStateService.var2));
Seeing 'b__3' instead of WCFServce.GetLabs(..) etc
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…