System.DefaultBinder.FindMostDerivedNewSlotMeth C# (CSharp) Method

FindMostDerivedNewSlotMeth() static private method

static private FindMostDerivedNewSlotMeth ( MethodBase match, int cMatches ) : MethodBase
match System.Reflection.MethodBase
cMatches int
return System.Reflection.MethodBase
        internal static MethodBase FindMostDerivedNewSlotMeth(MethodBase[] match, int cMatches)
        {
            int deepestHierarchy = 0;
            MethodBase methWithDeepestHierarchy = null;

            for (int i = 0; i < cMatches; i++)
            {
                // Calculate the depth of the hierarchy of the declaring type of the
                // current method.
                int currentHierarchyDepth = GetHierarchyDepth(match[i].DeclaringType);

                // Two methods with the same hierarchy depth are not allowed. This would
                // mean that there are 2 methods with the same name and sig on a given type
                // which is not allowed, unless one of them is vararg...
                if (currentHierarchyDepth == deepestHierarchy) {
                    BCLDebug.Assert(((match[i].CallingConvention & CallingConventions.VarArgs) |
                                    (methWithDeepestHierarchy.CallingConvention & CallingConventions.VarArgs)) != 0, 
                                    "Calling conventions: " + match[i].CallingConvention + " - " + methWithDeepestHierarchy.CallingConvention);
                    throw new AmbiguousMatchException(Environment.GetResourceString("RFLCT.Ambiguous"));
                }

                // Check to see if this method is on the most derived class.
                if (currentHierarchyDepth > deepestHierarchy)
                {
                    deepestHierarchy = currentHierarchyDepth;
                    methWithDeepestHierarchy = match[i];
                }
            }

            return methWithDeepestHierarchy;
        }

Usage Example

        // Token: 0x06000D98 RID: 3480 RVA: 0x00029940 File Offset: 0x00027B40
        public static MethodBase ExactBinding(MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
        {
            if (match == null)
            {
                throw new ArgumentNullException("match");
            }
            MethodBase[] array = new MethodBase[match.Length];
            int          num   = 0;

            for (int i = 0; i < match.Length; i++)
            {
                ParameterInfo[] parametersNoCopy = match[i].GetParametersNoCopy();
                if (parametersNoCopy.Length != 0)
                {
                    int j;
                    for (j = 0; j < types.Length; j++)
                    {
                        Type parameterType = parametersNoCopy[j].ParameterType;
                        if (!parameterType.Equals(types[j]))
                        {
                            break;
                        }
                    }
                    if (j >= types.Length)
                    {
                        array[num] = match[i];
                        num++;
                    }
                }
            }
            if (num == 0)
            {
                return(null);
            }
            if (num == 1)
            {
                return(array[0]);
            }
            return(DefaultBinder.FindMostDerivedNewSlotMeth(array, num));
        }
All Usage Examples Of System.DefaultBinder::FindMostDerivedNewSlotMeth