internal static void CacheMethod( MethodInformation mi, object target, string methodName, object[] arguments, CallsiteCacheEntryFlags flags) { Type targetType = (flags & (CallsiteCacheEntryFlags.Static | CallsiteCacheEntryFlags.Constructor)) == CallsiteCacheEntryFlags.None ? target.GetType() : (Type)target; if (targetType == typeof(PSObject) || targetType == typeof(PSCustomObject)) { return; } CallsiteSignature signature = new CallsiteSignature(targetType, arguments, flags); CallsiteCacheEntry key = new CallsiteCacheEntry(methodName, signature); lock (Adapter.callsiteCache) { if (Adapter.callsiteCache.ContainsKey(key)) { return; } if (Adapter.callsiteCache.Count > 2048) { Adapter.callsiteCache.Clear(); } Adapter.callsiteCache[key] = mi; } }
internal static MethodInformation FindCachedMethod( Type targetType, string methodName, object[] arguments, CallsiteCacheEntryFlags flags) { if (targetType == typeof(PSObject) || targetType == typeof(PSCustomObject)) { return((MethodInformation)null); } CallsiteSignature signature = new CallsiteSignature(targetType, arguments, flags); CallsiteCacheEntry key = new CallsiteCacheEntry(methodName, signature); MethodInformation methodInformation = (MethodInformation)null; lock (Adapter.callsiteCache) Adapter.callsiteCache.TryGetValue(key, out methodInformation); return(methodInformation); }