public static T Cache <T>(this MethodBase method, object instance, object[] arguments, Method <T> methodBody) where T : class { var key = method.DeclaringType.GUID + ":" + method.Name; if (instance != null) { key += instance.GetHashCode() + ":"; } arguments?.Do(arg => key += arg.GetHashCode() + ":"); if (CallContext.GetData(key) == null) { var result = methodBody?.Invoke(); CallContext.SetData(key, result); return(result); } return(CallContext.GetData(key) as T); }