System.Reflection.Binder.SelectMethod C# (CSharp) Method

SelectMethod() public abstract method

public abstract SelectMethod ( BindingFlags bindingAttr, Array match, Array types, Array modifiers ) : MethodBase
bindingAttr BindingFlags
match Array
types Array
modifiers Array
return MethodBase
        public abstract MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers);
        public abstract PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers);

Usage Example

Esempio n. 1
0
        public override MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] argumentTypes, ParameterModifier[] modifiers)
#endif
        {
            if (match.Length == 0)
            {
                return(null);
            }
#if CSHARP8
            MethodBase?result = null;
#else
            MethodBase result = null;
#endif
            // SelectMethod on the default binder throws an exception if passed
            // typebuilders. this comes up when trying to bind to proxy methods
            // during analysis when (the proxy type is not yet complete). we
            // skip the default binder in this case and fall back on our own logic
            bool allRuntimeTypes = true;
            for (var i = 0; i < argumentTypes.Length; i++)
            {
                if (argumentTypes[i] is System.Reflection.Emit.TypeBuilder)
                {
                    allRuntimeTypes = false;
                    break;
                }
            }
            if (allRuntimeTypes)
            {
                result = _binder.SelectMethod(bindingAttr, match, argumentTypes, modifiers);
            }
            if (result != null)
            {
                return(result);
            }
            foreach (var candidate in match)
            {
                if (MatchByMagicBindingRules(bindingAttr, candidate, argumentTypes, modifiers))
                {
                    if (result != null)
                    {
                        throw new AmbiguousMatchException();
                    }
                    else
                    {
                        result = candidate;
                        continue;
                    }
                }
            }

            return(result);
        }
All Usage Examples Of System.Reflection.Binder::SelectMethod