public override bool Equals(object obj) { MethodCacheKey key = obj as MethodCacheKey; if (key != null && key.TypeName == this.TypeName && key.MethodName == this.MethodName && ArrayEquals(key.ParamTypes, this.ParamTypes)) { return(true); } return(false); }
private static DynamicMethodHandle GetCachedMethod(object obj, MethodInfo info, params object[] parameters) { var key = new MethodCacheKey(obj.GetType().FullName, info.Name, GetParameterTypes(parameters)); DynamicMethodHandle mh = null; if (!_methodCache.TryGetValue(key, out mh)) { lock (_methodCache) { if (!_methodCache.TryGetValue(key, out mh)) { mh = new DynamicMethodHandle(info, parameters); _methodCache.Add(key, mh); } } } return mh; }
private static DynamicMethodHandle GetCachedMethod(object obj, MethodInfo info, params object[] parameters) { var key = new MethodCacheKey(obj.GetType().FullName, info.Name, GetParameterTypes(parameters)); DynamicMethodHandle mh = null; if (!_methodCache.TryGetValue(key, out mh)) { lock (_methodCache) { if (!_methodCache.TryGetValue(key, out mh)) { mh = new DynamicMethodHandle(info, parameters); _methodCache.Add(key, mh); } } } return(mh); }
internal static DynamicMemberHandle GetCachedProperty(Type objectType, string propertyName) { var key = new MethodCacheKey(objectType.FullName, propertyName, GetParameterTypes(null)); DynamicMemberHandle mh = null; if (!_memberCache.TryGetValue(key, out mh)) { lock (_memberCache) { if (!_memberCache.TryGetValue(key, out mh)) { PropertyInfo info = objectType.GetProperty(propertyName, propertyFlags); if (info == null) throw new InvalidOperationException( string.Format("Member not found on object ({0})", propertyName)); mh = new DynamicMemberHandle(info); _memberCache.Add(key, mh); } } } return mh; }
internal static DynamicMemberHandle GetCachedField(Type objectType, string fieldName) { var key = new MethodCacheKey(objectType.FullName, fieldName, GetParameterTypes(null)); DynamicMemberHandle mh = null; if (!_memberCache.TryGetValue(key, out mh)) { lock (_memberCache) { if (!_memberCache.TryGetValue(key, out mh)) { FieldInfo info = objectType.GetField(fieldName, fieldFlags); if (info == null) { throw new InvalidOperationException( string.Format("Resources.MemberNotFoundException:{0}", fieldName)); } mh = new DynamicMemberHandle(info); _memberCache.Add(key, mh); } } } return(mh); }
internal static DynamicMemberHandle GetCachedProperty(Type objectType, string propertyName) { var key = new MethodCacheKey(objectType.FullName, propertyName, GetParameterTypes(null)); DynamicMemberHandle mh = null; if (!_memberCache.TryGetValue(key, out mh)) { lock (_memberCache) { if (!_memberCache.TryGetValue(key, out mh)) { PropertyInfo info = objectType.GetProperty(propertyName, propertyFlags); if (info == null) { throw new InvalidOperationException( string.Format("Member not found on object ({0})", propertyName)); } mh = new DynamicMemberHandle(info); _memberCache.Add(key, mh); } } } return(mh); }
internal static DynamicMemberHandle GetCachedField(Type objectType, string fieldName) { var key = new MethodCacheKey(objectType.FullName, fieldName, GetParameterTypes(null)); DynamicMemberHandle mh = null; if (!_memberCache.TryGetValue(key, out mh)) { lock (_memberCache) { if (!_memberCache.TryGetValue(key, out mh)) { FieldInfo info = objectType.GetField(fieldName, fieldFlags); if (info == null) throw new InvalidOperationException( string.Format("Resources.MemberNotFoundException:{0}", fieldName)); mh = new DynamicMemberHandle(info); _memberCache.Add(key, mh); } } } return mh; }