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); }
public bool Equals(PSMethodInvocationConstraints other) { if (object.ReferenceEquals(null, other)) { return(false); } if (!object.ReferenceEquals(this, other)) { if (!object.Equals(other.MethodTargetType, this.MethodTargetType)) { return(false); } if (!CallsiteSignature.EqualsForCollection <Type>(this.parameterTypes, other.parameterTypes)) { return(false); } } return(true); }
internal CallsiteCacheEntry(string methodName, CallsiteSignature signature) { this.methodName = methodName; this.signature = signature; }