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);
        }
示例#2
0
 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;
 }
示例#3
0
        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);
        }
示例#4
0
 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;
 }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
 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;
 }