Mono Class Library: System.Reflection NamespaceSystem.Reflection.Binder Class |
See Also: Binder Members
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
Late binding is controlled by a customized binding interface through reflection. The System.Reflection.Binder class is designed to provide this functionality. System.Reflection.Binder objects are used in overload resolution and argument coercion for dynamic invocation of members at runtime.
Access to information obtained from reflection is controlled at two levels: untrusted code and code with System.Security.Permissions.ReflectionPermission.
Untrusted code is code with no special level of trust (such as code downloaded from the Internet). Such code is allowed to invoke anything that it would have been able to invoke in an early bound way.
System.Security.Permissions.ReflectionPermission controls access to metadata through reflection. If this permission is granted to code, that code has access to all the types in its application domain, assembly, and module. It can access information about public, family, and private members of all types it has access to. Two primary capabilities are granted:
- The ability to read the metadata for family and private members of any type.
- The ability to access peer classes in the module and peer modules in the assembly.
Note:[Edit]The term "reflection" refers to the ability to obtain information about a object during runtime. The primary means through which this information is accessed is via the Type of the object. Reflection allows the programmatic discovery of a type's metadata. The information included in the metadata includes details about the assembly or module in which the type is defined as well as members of the type. Reflection uses this information to provide the following primary services:
- Access to type information at runtime.
- The ability to use this type information to create instances, invoke methods, and access data members of the type.
The primary users of these services are script engines, object viewers, compilers, and object persistence formatters.
Through reflection, methods can be bound and invoked at runtime. If more than one member exists for a given member name, overload resolution determines which implementation of that method is invoked by the system. Coercion can occur when a parameter specified for a method call does not match the type specified for the parameter in the method signature. When possible, the binder converts the parameter (coerces it) to the type specified by the method signature. Coercion might not be possible depending on the types involved.
To bind to a method, field, or property, typically a list of probable candidates is obtained from the Type of a object. That list is the passed to the appropriate method of a System.Reflection.Binder instance. Based on the other parameters passed to that method, typically (although not necessarily) one of the members of the list is chosen, and an object that reflects that member is returned.
The system supplies a default binder that provides default binding rules. Because binding rules vary among programming languages, it is recommended that each programming language provide a custom implementation of System.Reflection.Binder .
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0