Ejemplo n.º 1
0
        public static MethodGroup GetMethodGroup(string name, MemberGroup mems)
        {
            MethodGroup res = null;

            MethodBase[]    bases    = new MethodBase[mems.Count];
            MethodTracker[] trackers = new MethodTracker[mems.Count];
            for (int i = 0; i < bases.Length; i++)
            {
                trackers[i] = (MethodTracker)mems[i];
                bases[i]    = trackers[i].Method;
            }

            if (mems.Count != 0)
            {
                MethodBaseCache cache = new MethodBaseCache(name, bases);
                lock (_functions) {
                    if (!_functions.TryGetValue(cache, out res))
                    {
                        _functions[cache] = res = new MethodGroup(trackers);
                    }
                }
            }

            return(res);
        }
Ejemplo n.º 2
0
 public static MethodGroup GetMethodGroup(string name, MethodBase[] methods) {
     MethodGroup res = null;
     MethodBaseCache cache = new MethodBaseCache(name, methods);
     lock (_functions) {
         if (!_functions.TryGetValue(cache, out res)) {
             _functions[cache] = res = new MethodGroup(
                 ArrayUtils.ConvertAll<MethodBase, MethodTracker>(
                     methods,
                     delegate(MethodBase x) {
                         return (MethodTracker)MemberTracker.FromMemberInfo(x);
                     }
                 )
             );
         }
     }
     return res;
 }
Ejemplo n.º 3
0
            public override bool Equals(object obj)
            {
                MethodBaseCache other = obj as MethodBaseCache;

                if (other == null || _members.Length != other._members.Length || other._name != _name)
                {
                    return(false);
                }

                for (int i = 0; i < _members.Length; i++)
                {
                    MethodBase member      = _members[i];
                    MethodBase otherMember = other._members[i];

                    if (member.DeclaringType != otherMember.DeclaringType ||
                        member.IsGenericMethod != otherMember.IsGenericMethod ||
#if NETSTANDARD
                        member.HasMetadataToken() && otherMember.HasMetadataToken() &&
#endif
                        member.GetMetadataToken() != otherMember.GetMetadataToken())
                    {
                        return(false);
                    }

                    if (member.IsGenericMethod)
                    {
                        Type[] args      = member.GetGenericArguments();
                        Type[] otherArgs = otherMember.GetGenericArguments();

                        if (args.Length != otherArgs.Length)
                        {
                            return(false);
                        }

                        for (int j = 0; j < args.Length; j++)
                        {
                            if (args[j] != otherArgs[j])
                            {
                                return(false);
                            }
                        }
                    }
                }

                return(true);
            }
Ejemplo n.º 4
0
            public override bool Equals(object obj)
            {
                MethodBaseCache other = obj as MethodBaseCache;

                if (other == null || _members.Length != other._members.Length)
                {
                    return(false);
                }
                if (other._name != _name)
                {
                    return(false);
                }

                for (int i = 0; i < _members.Length; i++)
                {
                    if (_members[i].DeclaringType != other._members[i].DeclaringType ||
                        _members[i].MetadataToken != other._members[i].MetadataToken ||
                        _members[i].IsGenericMethod != other._members[i].IsGenericMethod)
                    {
                        return(false);
                    }

                    if (_members[i].IsGenericMethod)
                    {
                        Type[] args      = _members[i].GetGenericArguments();
                        Type[] otherArgs = other._members[i].GetGenericArguments();

                        if (args.Length != otherArgs.Length)
                        {
                            return(false);
                        }

                        for (int j = 0; j < args.Length; j++)
                        {
                            if (args[j] != otherArgs[j])
                            {
                                return(false);
                            }
                        }
                    }
                }

                return(true);
            }
Ejemplo n.º 5
0
            public override bool Equals(object obj)
            {
                MethodBaseCache other = obj as MethodBaseCache;

                if (other == null || _members.Length != other._members.Length || other._name != _name)
                {
                    return(false);
                }

                for (int i = 0; i < _members.Length; i++)
                {
                    if (_members[i].DeclaringType != other._members[i].DeclaringType ||
                        _members[i].IsGenericMethod != other._members[i].IsGenericMethod ||
                        //MetadataToken causes exception on CoreRT
                        //https://github.com/dotnet/corert/blob/db9c9ced21afd0848c748960358832bc3e41ae62/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/NativeFormat/NativeFormatMethodCommon.cs#L184
                        (PlatformAdaptationLayer.IsNativeModule ? false : _members[i].MetadataToken != other._members[i].MetadataToken))
                    {
                        return(false);
                    }

                    if (_members[i].IsGenericMethod)
                    {
                        Type[] args      = _members[i].GetGenericArguments();
                        Type[] otherArgs = other._members[i].GetGenericArguments();

                        if (args.Length != otherArgs.Length)
                        {
                            return(false);
                        }

                        for (int j = 0; j < args.Length; j++)
                        {
                            if (args[j] != otherArgs[j])
                            {
                                return(false);
                            }
                        }
                    }
                }

                return(true);
            }
Ejemplo n.º 6
0
        public static MethodGroup GetMethodGroup(string name, MethodBase[] methods)
        {
            MethodGroup     res   = null;
            MethodBaseCache cache = new MethodBaseCache(name, methods);

            lock (_functions) {
                if (!_functions.TryGetValue(cache, out res))
                {
                    _functions[cache] = res = new MethodGroup(
                        ArrayUtils.ConvertAll <MethodBase, MethodTracker>(
                            methods,
                            delegate(MethodBase x) {
                        return((MethodTracker)MemberTracker.FromMemberInfo(x));
                    }
                            )
                        );
                }
            }
            return(res);
        }
Ejemplo n.º 7
0
        public static MethodGroup GetMethodGroup(string name, MemberGroup mems) {
            MethodGroup res = null;

            MethodBase[] bases = new MethodBase[mems.Count];
            MethodTracker[] trackers = new MethodTracker[mems.Count];
            for (int i = 0; i < bases.Length; i++) {
                trackers[i] = (MethodTracker)mems[i];
                bases[i] = trackers[i].Method;
            }

            if (mems.Count != 0) {
                MethodBaseCache cache = new MethodBaseCache(name, bases);
                lock (_functions) {
                    if (!_functions.TryGetValue(cache, out res)) {
                        _functions[cache] = res = new MethodGroup(trackers);
                    }
                }
            }

            return res;
        }