mscorlib(4.0.0.0) API with additions
System.Reflection.Binder Class Referenceabstract

Selects a member from a list of candidates, and performs type conversion from actual argument type to formal argument type. More...

Inherited by System.DefaultBinder.

Public Member Functions

abstract MethodBase BindToMethod (BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state)
 Selects a method to invoke from the given set of methods, based on the supplied arguments. More...
 
abstract FieldInfo BindToField (BindingFlags bindingAttr, FieldInfo[] match, object value, CultureInfo culture)
 Selects a field from the given set of fields, based on the specified criteria. More...
 
abstract MethodBase SelectMethod (BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
 Selects a method from the given set of methods, based on the argument type. More...
 
abstract PropertyInfo SelectProperty (BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers)
 Selects a property from the given set of properties, based on the specified criteria. More...
 
abstract object ChangeType (object value, Type type, CultureInfo culture)
 Changes the type of the given Object to the given Type. More...
 
abstract void ReorderArgumentArray (ref object[] args, object state)
 Upon returning from M:System.Reflection.Binder.BindToMethod(System.Reflection.BindingFlags,System.Reflection.MethodBase[],System.Object[]@,System.Reflection.ParameterModifier[],System.Globalization.CultureInfo,System.String[],System.Object@), restores the args argument to what it was when it came from BindToMethod. More...
 

Detailed Description

Selects a member from a list of candidates, and performs type conversion from actual argument type to formal argument type.

Definition at line 10 of file Binder.cs.

Member Function Documentation

◆ BindToField()

abstract FieldInfo System.Reflection.Binder.BindToField ( BindingFlags  bindingAttr,
FieldInfo []  match,
object  value,
CultureInfo  culture 
)
pure virtual

Selects a field from the given set of fields, based on the specified criteria.

Parameters
bindingAttrA bitwise combination of T:System.Reflection.BindingFlags values.
matchThe set of fields that are candidates for matching. For example, when a T:System.Reflection.Binder object is used by Overload:System.Type.InvokeMember, this parameter specifies the set of fields that reflection has determined to be possible matches, typically because they have the correct member name. The default implementation provided by P:System.Type.DefaultBinder changes the order of this array.
valueThe field value used to locate a matching field.
cultureAn instance of T:System.Globalization.CultureInfo that is used to control the coercion of data types, in binder implementations that coerce types. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.Note   For example, if a binder implementation allows coercion of string values to numeric types, this parameter is necessary to convert a String that represents 1000 to a Double value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions.
Returns
The matching field.
Exceptions
T:System.Reflection.AmbiguousMatchExceptionFor the default binder, bindingAttr includes F:System.Reflection.BindingFlags.SetField, and match contains multiple fields that are equally good matches for value . For example, value contains a MyClass object that implements the IMyClass interface, and match contains a field of type MyClass and a field of type IMyClass.
T:System.MissingFieldExceptionFor the default binder, bindingAttr includes F:System.Reflection.BindingFlags.SetField, and match contains no fields that can accept value .
T:System.NullReferenceExceptionFor the default binder, bindingAttr includes F:System.Reflection.BindingFlags.SetField, and match is null or an empty array.-or- bindingAttr includes F:System.Reflection.BindingFlags.SetField, and value is null.

◆ BindToMethod()

abstract MethodBase System.Reflection.Binder.BindToMethod ( BindingFlags  bindingAttr,
MethodBase []  match,
ref object []  args,
ParameterModifier []  modifiers,
CultureInfo  culture,
string []  names,
out object  state 
)
pure virtual

Selects a method to invoke from the given set of methods, based on the supplied arguments.

Parameters
bindingAttrA bitwise combination of T:System.Reflection.BindingFlags values.
matchThe set of methods that are candidates for matching. For example, when a T:System.Reflection.Binder object is used by Overload:System.Type.InvokeMember, this parameter specifies the set of methods that reflection has determined to be possible matches, typically because they have the correct member name. The default implementation provided by P:System.Type.DefaultBinder changes the order of this array.
argsThe arguments that are passed in. The binder can change the order of the arguments in this array; for example, the default binder changes the order of arguments if the names parameter is used to specify an order other than positional order. If a binder implementation coerces argument types, the types and values of the arguments can be changed as well.
modifiersAn array of parameter modifiers that enable binding to work with parameter signatures in which the types have been modified. The default binder implementation does not use this parameter.
cultureAn instance of T:System.Globalization.CultureInfo that is used to control the coercion of data types, in binder implementations that coerce types. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used. Note   For example, if a binder implementation allows coercion of string values to numeric types, this parameter is necessary to convert a String that represents 1000 to a Double value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions.
namesThe parameter names, if parameter names are to be considered when matching, or null if arguments are to be treated as purely positional. For example, parameter names must be used if arguments are not supplied in positional order.
stateAfter the method returns, state contains a binder-provided object that keeps track of argument reordering. The binder creates this object, and the binder is the sole consumer of this object. If state is not null when BindToMethod returns, you must pass state to the M:System.Reflection.Binder.ReorderArgumentArray(System.Object[]@,System.Object) method if you want to restore args to its original order, for example, so that you can retrieve the values of ref parameters (ByRef parameters in Visual Basic).
Returns
The matching method.
Exceptions
T:System.Reflection.AmbiguousMatchExceptionFor the default binder, match contains multiple methods that are equally good matches for args . For example, args contains a MyClass object that implements the IMyClass interface, and match contains a method that takes MyClass and a method that takes IMyClass.
T:System.MissingMethodExceptionFor the default binder, match contains no methods that can accept the arguments supplied in args .
T:System.ArgumentExceptionFor the default binder, match is null or an empty array.

◆ ChangeType()

abstract object System.Reflection.Binder.ChangeType ( object  value,
Type  type,
CultureInfo  culture 
)
pure virtual

Changes the type of the given Object to the given Type.

Parameters
valueThe object to change into a new Type.
typeThe new Type that value will become.
cultureAn instance of T:System.Globalization.CultureInfo that is used to control the coercion of data types. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.Note   For example, this parameter is necessary to convert a String that represents 1000 to a Double value, because 1000 is represented differently by different cultures.
Returns
An object that contains the given value as the new type.

◆ ReorderArgumentArray()

abstract void System.Reflection.Binder.ReorderArgumentArray ( ref object []  args,
object  state 
)
pure virtual

Upon returning from M:System.Reflection.Binder.BindToMethod(System.Reflection.BindingFlags,System.Reflection.MethodBase[],System.Object[]@,System.Reflection.ParameterModifier[],System.Globalization.CultureInfo,System.String[],System.Object@), restores the args argument to what it was when it came from BindToMethod.

Parameters
argsThe actual arguments that are passed in. Both the types and values of the arguments can be changed.
stateA binder-provided object that keeps track of argument reordering.

◆ SelectMethod()

abstract MethodBase System.Reflection.Binder.SelectMethod ( BindingFlags  bindingAttr,
MethodBase []  match,
Type []  types,
ParameterModifier []  modifiers 
)
pure virtual

Selects a method from the given set of methods, based on the argument type.

Parameters
bindingAttrA bitwise combination of T:System.Reflection.BindingFlags values.
matchThe set of methods that are candidates for matching. For example, when a T:System.Reflection.Binder object is used by Overload:System.Type.InvokeMember, this parameter specifies the set of methods that reflection has determined to be possible matches, typically because they have the correct member name. The default implementation provided by P:System.Type.DefaultBinder changes the order of this array.
typesThe parameter types used to locate a matching method.
modifiersAn array of parameter modifiers that enable binding to work with parameter signatures in which the types have been modified.
Returns
The matching method, if found; otherwise, null.
Exceptions
T:System.Reflection.AmbiguousMatchExceptionFor the default binder, match contains multiple methods that are equally good matches for the parameter types described by types . For example, the array in types contains a T:System.Type object for MyClass and the array in match contains a method that takes a base class of MyClass and a method that takes an interface that MyClass implements.
T:System.ArgumentExceptionFor the default binder, match is null or an empty array.-or-An element of types derives from T:System.Type, but is not of type RuntimeType.

◆ SelectProperty()

abstract PropertyInfo System.Reflection.Binder.SelectProperty ( BindingFlags  bindingAttr,
PropertyInfo []  match,
Type  returnType,
Type []  indexes,
ParameterModifier []  modifiers 
)
pure virtual

Selects a property from the given set of properties, based on the specified criteria.

Parameters
bindingAttrA bitwise combination of T:System.Reflection.BindingFlags values.
matchThe set of properties that are candidates for matching. For example, when a T:System.Reflection.Binder object is used by Overload:System.Type.InvokeMember, this parameter specifies the set of properties that reflection has determined to be possible matches, typically because they have the correct member name. The default implementation provided by P:System.Type.DefaultBinder changes the order of this array.
returnTypeThe return value the matching property must have.
indexesThe index types of the property being searched for. Used for index properties such as the indexer for a class.
modifiersAn array of parameter modifiers that enable binding to work with parameter signatures in which the types have been modified.
Returns
The matching property.
Exceptions
T:System.Reflection.AmbiguousMatchExceptionFor the default binder, match contains multiple properties that are equally good matches for returnType and indexes .
T:System.ArgumentExceptionFor the default binder, match is null or an empty array.

The documentation for this class was generated from the following file: