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)) return 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)) { return(mh); } lock (_methodCache) { if (!_methodCache.TryGetValue(key, out mh)) { mh = new DynamicMethodHandle(info, parameters); _methodCache.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)) { return(mh); } lock (_memberCache) { if (!_memberCache.TryGetValue(key, out mh)) { FieldInfo info = objectType.GetField(fieldName, fieldFlags); if (info != null) { 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)) { return(mh); } lock (_memberCache) { if (!_memberCache.TryGetValue(key, out mh)) { PropertyInfo info = FindProperty(objectType, propertyName); if (info != null) { 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)) return mh; lock (_memberCache) { if (!_memberCache.TryGetValue(key, out mh)) { PropertyInfo info = FindProperty(objectType, propertyName); if (info != null) 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)) return mh; lock (_memberCache) { if (!_memberCache.TryGetValue(key, out mh)) { FieldInfo info = objectType.GetField(fieldName, fieldFlags); if (info != null) mh = new DynamicMemberHandle(info); _memberCache.Add(key, mh); } } return mh; }