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

BindToMethod() public abstract method

public abstract BindToMethod ( BindingFlags bindingAttr, Array match, Array &args, Array modifiers, CultureInfo culture, Array names, object &state ) : MethodBase
bindingAttr BindingFlags
match Array
args Array
modifiers Array
culture CultureInfo
names Array
state object
return MethodBase
        public abstract MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state);
        public abstract object ChangeType(object value, Type type, CultureInfo culture);

Usage Example

Esempio n. 1
0
        public override MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state)
#endif
        {
            try {
                var nativeResult = _binder.BindToMethod(bindingAttr, match, ref args, modifiers, culture, names, out state);
                if (nativeResult != null)
                {
                    return(nativeResult);
                }
            } catch (MissingMemberException) {
                // ignore
            }
            var argumentTypes = args.Select(a => a == null ? typeof(Object) : a.GetType()).ToArray();

            state = new Object(); // ???
            var result = SelectMethod(bindingAttr, match, argumentTypes, modifiers);

            if (result != null)
            {
                var parameters = result.GetParameters();
                for (int i = 0; i < args.Length; i++)
                {
                    // this is assumed to work at this point. a situation where
                    // we could not convert the argument types should not have
                    // bound and SelectMethod should have returned null
                    if (parameters[i].ParameterType.IsEnum)
                    {
                        args[i] = Enum.ToObject(parameters[i].ParameterType, args[i]);
                    }
                    else
                    {
                        args[i] = Convert.ChangeType(args[i], parameters[i].ParameterType);
                    }
                }
            }

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