Class ReflectionUtility
Reflection Utility Methods.
Inheritance
Inherited Members
Namespace: StansAssets.Foundation
Assembly: cs.temp.dll.dll
Syntax
public static class ReflectionUtility
Fields
BuiltInAssemblyPrefixes
Collection of predefined built-in assembly prefixes. Mono.
, UnityEditor.
, Unity.
, UnityEngine
, System
and mscorlib
prefixes included.
Declaration
public static readonly string[] BuiltInAssemblyPrefixes
Field Value
Type | Description |
---|---|
System.String[] |
Methods
CreateInstance(String)
Creates an instance of the specified System.Type using that type's parameterless constructor.
Declaration
public static object CreateInstance(string typeFullName)
Parameters
Type | Name | Description |
---|---|---|
System.String | typeFullName | Full type name of the instance to create. |
Returns
Type | Description |
---|---|
System.Object | New System.Object instance of the specified type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException | System.Type specified with |
FindImplementationsOf(Type, IEnumerable<String>)
Searched for the implementations of the System.Type specified with baseType
.
Declaration
public static IEnumerable<Type> FindImplementationsOf(Type baseType, IEnumerable<string> ignoreAssemblyPrefixes = null)
Parameters
Type | Name | Description |
---|---|---|
System.Type | baseType | Specifies the System.Type whose implementations to search for. |
IEnumerable<System.String> | ignoreAssemblyPrefixes | Collection of assembly prefixes to skip. The System.Reflection.Assembly will be ignored if its name starts with one of these prefixes. |
Returns
Type | Description |
---|---|
IEnumerable<System.Type> | A collection of System.Type objects that are implementations of |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
FindImplementationsOf<T>(IEnumerable<String>)
Searched for the implementations of the System.Type specified with T
.
Declaration
public static IEnumerable<Type> FindImplementationsOf<T>(IEnumerable<string> ignoreAssemblyPrefixes = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.String> | ignoreAssemblyPrefixes | Collection of assembly prefixes to skip. The System.Reflection.Assembly will be ignored if its name starts with one of these prefixes. |
Returns
Type | Description |
---|---|
IEnumerable<System.Type> | A collection of System.Type objects that are implementations of |
Type Parameters
Name | Description |
---|---|
T | Specifies the System.Type whose implementations to search for. |
FindMethodsWithCustomAttributes<T>(BindingFlags, Boolean, IEnumerable<String>)
Searches for the methods with custom attribute of type T
.
Declaration
public static IEnumerable<MethodInfo> FindMethodsWithCustomAttributes<T>(BindingFlags methodBindingFlags = null, bool inherit = true, IEnumerable<string> ignoreAssemblyPrefixes = null)
where T : Attribute
Parameters
Type | Name | Description |
---|---|---|
BindingFlags | methodBindingFlags | A bitwise combination of the enumeration values that specify how the search is conducted. |
System.Boolean | inherit |
|
IEnumerable<System.String> | ignoreAssemblyPrefixes | Collection of assembly prefixes to skip. The System.Reflection.Assembly will be ignored if its name starts with one of these prefixes. |
Returns
Type | Description |
---|---|
IEnumerable<MethodInfo> | A collection of System.Reflection.MethodInfo objects representing all methods defined for the current System.Type that match the specified binding constraints and attributes type. |
Type Parameters
Name | Description |
---|---|
T | Specifies the System.Type of the custom attribute to search for. |
FindType(String)
Searches for the specified System.Type in all assemblies of the current application domain.
Declaration
public static Type FindType(string typeFullName)
Parameters
Type | Name | Description |
---|---|---|
System.String | typeFullName | Full type's name to search for. |
Returns
Type | Description |
---|---|
System.Type | System.Type object found via specified |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.InvalidOperationException | No types matching |
GetAssemblies(IEnumerable<String>)
Gets the assemblies that have been loaded into the execution context of this application domain.
Declaration
public static IEnumerable<Assembly> GetAssemblies(IEnumerable<string> ignoreAssemblyPrefixes = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.String> | ignoreAssemblyPrefixes | Collection of assembly prefixes to skip. The System.Reflection.Assembly will be ignored if its name starts with one of these prefixes. |
Returns
Type | Description |
---|---|
IEnumerable<Assembly> | A collection of assemblies in this application domain. |
GetPropertyValue(Object, String, BindingFlags)
Returns the property value of a specified object.
Declaration
public static object GetPropertyValue(object src, string propName, BindingFlags bindingAttr = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | src | The object whose property value will be returned. |
System.String | propName | The string containing the name of the public property to get. |
BindingFlags | bindingAttr | A bitwise combination of the enumeration values that specify how the search is conducted. |
Returns
Type | Description |
---|---|
System.Object | The property value of the specified object. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException | Property specified with the |
SetPropertyValue<T>(Object, String, T, BindingFlags)
Sets the property value of a specified object.
Declaration
public static void SetPropertyValue<T>(object src, string propName, T propValue, BindingFlags bindingAttr = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | src | The object whose property value will be set. |
System.String | propName | The string containing the name of the property to get. |
T | propValue | The new property value. |
BindingFlags | bindingAttr | A bitwise combination of the enumeration values that specify how the search is conducted. |
Type Parameters
Name | Description |
---|---|
T | Specifies the System.Type of property value to set. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException | Property specified with the |