Comprises flags that control binding and the way in which the search for members and types is conducted using Reflection.
[Visual Basic] Public Enum BindingFlags [C#] public enum BindingFlags [C++] public enum BindingFlags
[JScript] In JScript, you can use the enumerations in the NGWS frameworks, but you cannot define your own.
BindingFlags provides enumerators for a great many classes in the System, System.Reflection, and System.Runtime namespaces that invoke, create, get, set, and find members and types.
BindingFlags are used in the following Type methods and other places such as Invoke:
InvokeMember, GetMethod, and Invoke are especially important.
InvokeMember and GetMethod find methods by using the DefaultBinding, ExactBinding, BinderBinding, and DefaultValueBinding flags.
Invoke methods change types to match the target signature. These use the DefaultChangeType, ExactChangeType, BinderChangeType, and DefaultValueChangeType enumerators. The Default enumerator aggregates the DefaultBinding, DefaultChangeType, and DefaultLookup flags. For more control, specify the proper combination. This means if you provide a binder you must specify both BinderChangeType and BinderBinding.
Filter and modifier flags are used for searching. Filter flags (Instance, Static, Public, and NonPublic) as used by the Lookup enumerators are bit flags indicating that members of that type should be included in the search.
Modifier flags are either on or off, and change how the search works. The modifier flags are IgnoreCase and DeclaredOnly.
Three aggregate enumerators indicate normal use of the binding flags: DefaultLookup, LookupAll, and Default. Use Default or DefaultLookup in searches. The Default flag aggregates the DefaultBinding, DefaultChangeType, and DefaultLookup flags. Default is the normal flag used by InvokeMember. Use LookupAll in places where BindingFlags.NonPublic was used.
Arguments to InvokeMember and CreateInstance don't require specifying the lookup bits. Type.InvokeMember uses DefaultLookup and CreateInstance uses Public or Instance.
Member Name | Description |
---|---|
BinderBinding | Specifies that change type will be handled by the binder. A binder must be provided. BinderBinding may not be combined with ExactBinding or DefaultBinding. |
BinderChangeType | Specifies that change type will be handled by the binder. A binder must be provided. BinderChangeType may not be combined with ExactChangeType or DefaultChangeType. |
BinderFull | Combines BinderBinding and BinderChangeType. |
CallNonVirt | Specifies that the Invoke is not to be virtualized. |
ConstructorDefault | [To be supplied.] |
ConstructorLookupAll | [To be supplied.] |
CreateInstance | Specifies that an instance of the type is to be created. Calls the constructor that matches the given arguments. Not valid with any other InvokeMember enumerator. The member name is ignored. |
DeclaredOnly | Specifies that only members declared at this level of the type hierarchy, and not inherited method, should be considered. |
Default | Specifies that the default binding rules are used. DefaultBinding may not be combined with ExactBinding or BinderBinding. DefaultChangeType may not be combined with ExactChangeType or BinderChangeType.
The default binder does not follow any particular language's binding rules, rather relying on each language to provide its own binding. |
DefaultBinding | Specifies that the system default binding rules should be used. DefaultBinding may not be combined with ExactBinding or BinderBinding. |
DefaultChangeType | Specifies that the default change type rules are to be used. DefaultChangeType may not be combined with ExactChangeType or BinderChangeType. |
DefaultLookup | Aggregates three bit flags to indicate that members of that type should be included in the search.
Arguments to InvokeMember and CreateInstance don't require specifying the lookup bits. System.Type.InvokeMember uses DefaultLookup and System.Activator.CreateInstance uses the Public or Instance flag. |
DefaultValueBinding | Returns the set of methods that have a specified number of parameters. This is used for default values, varargs, and so on. DefaultValueBinding may be combined with other binding options. |
DefaultValueChangeType | Returns the set of methods of the specified type. This is used for default values, varargs, and so on. DefaultValueChangeType may be combined with other binding options. |
DefaultValueFull | Combines DefaultValueBinding and DefaultValueChangeType. |
ExactBinding | Specifies that exact data type matching is to be done. ExactBinding may not be combined with BinderBinding or DefaultBinding. |
ExactChangeType | Specifies that no change of type is to be done; the types of the actual arguments must match exactly with the types of the formal arguments. ExactChangeType may not be combined with BinderChangeType or DefaultChangeType. |
ExactFull | Combines ExactBinding and ExactChangeType. |
FlattenHierarchy | Specifies that static members are to be rolled up into the class. |
GetField | Specifies that the value of the specified field should be returned. |
GetProperty | Specifies that the value of the specified property should be returned. |
IgnoreCase | Specifies that the case of the member name is not to be considered. |
IgnoreReturn | Used in COM Interop. |
Instance | Specifies that instance members are to be included in the search. |
InvokeMethod | Specifies that a method is to be invoked. This may be not be the constructor or type initializer. |
LookupAll | Aggregate enumerator indicating normal use of the binding flags. Use LookupAll in places where NonPublic was used. |
NonPublic | Specifies that non-public members are to be included in the search. |
Public | Specifies that public members are to be included in the search. |
PutDispProperty | [To be supplied.] |
PutRefDispProperty | [To be supplied.] |
SetField | Specifies that the value of the specified field should be set. |
SetProperty | Specifies that the value of the specified property should be set. |
Static | Specifies that static members are to be included in the search. |
Namespace: System.Reflection
Assembly: mscorlib.dll