Summary
A variety of utility methods relating to reflection.
- Assembly
- Weaver
.dll - Namespace
- Weaver
- Base Types
-
- Object
graph BT
Type-->Base0["Object"]
Type["ReflectionUtilities"]
class Type type-node
Syntax
public static class ReflectionUtilities
Fields
Name | Constant Value | Summary |
---|---|---|
AnyAccessBindings | 60 |
System.Reflection.BindingFlags for any access modifiers.static
|
InstanceBindings | 52 |
System.Reflection.BindingFlags for instance access modifiers.static
|
Public |
20 |
System.Reflection.BindingFlags for public and instance.static
|
PublicStaticBindings | 24 |
System.Reflection.BindingFlags for public and static.static
|
StaticBindings | 56 |
System.Reflection.BindingFlags for static access modifiers.static
|
Methods
Name | Value | Summary |
---|---|---|
AppendDeepToString |
void |
Builds a string containing the values of each of the specified object's fields.
static
|
CanBeConst |
bool |
All built-in types except
System.Object can be const.
static
|
DeepToString |
string |
Builds a string containing the values of each of the specified object's fields.
static
|
For |
bool |
Calls `method` once for each attribute of the specified type on `target`.
static
|
ForEachType |
void |
Calls the specified method once for each type in every currently loaded assembly.
Most situations where you want to do something for each type are in reference to something specific.
For example: when searching for every type with a certain attribute, you only need to look in assemblies
that reference the assembly containing the attribute so you should instead use
Weaver.ReflectionUtilities .Weaver.ReflectionUtilities.Assemblies.ForEachTypeInDependantAssemblies(System.Reflection.Assembly,System.Action{System.Type}) .
static
|
GetAttribute |
TAttribute |
Gets a single custom attribute of type T and casts it.
static
|
GetAttributedFields |
void |
Gets all fields with the specified attribute in `type`.
static
|
GetAttributedMethods |
void |
Gets all methods with the specified attribute in every type in the currently loaded assemblies.
static
|
GetAttributedMethods |
void |
Gets all methods with the specified attribute in `type`.
static
|
Get |
void |
Gets all properties with the specified attribute in `type`.
static
|
GetAttributedTypes |
void |
Gets all types with the specified attribute all currently loaded assemblies.
static
|
GetDelegate |
T |
Creates a delegate of the specified type from `method`.
static
|
GetDelegate |
void |
Creates a delegate of the specified type from `method`.
static
|
GetDerivedTypes |
List |
Gets all non-abstract types in the currently loaded assemblies which derive from the specified base type
(starting with the base type itself if it isn't abstract).
static
|
GetDerivedTypes |
void |
Gets all non-abstract types in the currently loaded assemblies which derive from the specified base type
(starting with the base type itself if it isn't abstract).
static
|
Get |
Type[] |
If `type` implements the `interfaceType` this method returns the generic arguments it uses for that interface.
static
|
Get |
string |
Returns null, "override" or "new" as appropriate for a method called `methodName` in a child of `baseType`.
static
|
GetMemberFunc |
Func |
Tries to find a field/property/method in the `declaringType` with the `name` and creates a delegate to get
its value.
If a member is found but can't be converted to an appropriate delegate, the `error` message describes the
problem.
static
|
GetQualifiedName |
string |
Returns "
System.Type.FullName , System.Reflection.AssemblyName.Name ".static
|
HasFlags |
bool |
Checks if `bindings` contains all the flags in `flags`.
static
|
HasImplicitCast |
bool |
Returns true if `from` can be implicitly cast to `to`.
static
|
IsObsolete |
bool |
Checks if `target` has an [
System.ObsoleteAttribute ].static
|
Is |
bool |
Checks if `type` is descended from `generic` (where `generic` is a generic type definition).
static
|
Is |
bool |
Checks if `type` is descended from `generic` (where `generic` is a generic type definition).
static
|
OneObject |
Object[] |
Returns
System.Object [1] { obj }.
The array is kept in a field marked with [System.ThreadStaticAttribute ], so it is thread safe
but cannot be used recursively within a single thread.
static
|
OneType |
Type[] |
Returns
System.Type [1] { type }.
The array is kept in a field marked with [System.ThreadStaticAttribute ], so it is thread safe
but cannot be used recursively within a single thread.
static
|
ToAccessModifier |
string |
Returns a description of the access modifier associated with `bindings`
static
|
TwoObjects |
Object[] |
Returns
System.Object [2] { obj0, obj1 }.
The array is kept in a field marked with [System.ThreadStaticAttribute ], so it is thread safe
but cannot be used recursively within a single thread.
static
|
TwoTypes |
Type[] |
Returns
System.Type [2] { type0, type1 }.
The array is kept in a field marked with [System.ThreadStaticAttribute ], so it is thread safe
but cannot be used recursively within a single thread.
static
|