Class ReflectionExtensions
Inheritance
System.Object
ReflectionExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: cs.temp.dll.dll
Syntax
public static class ReflectionExtensions
Methods
CreateListOfType(Type)
Returns an 0 size IList of the given type.
This method is similar to new List<T> but allows to pass a type reference instead.
Declaration
public static IList CreateListOfType(Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
Returns
Type |
Description |
System.Collections.Generic.IList |
|
GetAllDerivedTypes<T>(AppDomain)
Returns all derives types for a given Type in the given AppDomain
Declaration
public static List<Type> GetAllDerivedTypes<T>(this AppDomain appDomain)
Parameters
Type |
Name |
Description |
System.AppDomain |
appDomain |
|
Returns
Type |
Description |
System.Collections.Generic.List<System.Type> |
|
Type Parameters
GetFieldValue<T>(Object, String)
Returns a field value from the property name and type using reflection.
Declaration
public static T GetFieldValue<T>(this object obj, string fieldName)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
System.String |
fieldName |
|
Returns
Type Parameters
GetInstanceFields(Type)
Returns all public instance field of a given type.
Declaration
public static FieldInfo[] GetInstanceFields(this Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
Returns
Type |
Description |
FieldInfo[] |
|
GetPropertyValue<T>(Object, String)
Returns a property value from the property name and type using reflection.
Declaration
public static T GetPropertyValue<T>(this object obj, string propertyName)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
System.String |
propertyName |
|
Returns
Type Parameters
HasAttribute<AttributeType>(MemberInfo)
Returns True if the given member has at least one Attribute of the given attribute type.
Declaration
public static bool HasAttribute<AttributeType>(this MemberInfo memberInfo)
Parameters
Type |
Name |
Description |
MemberInfo |
memberInfo |
Member
|
Returns
Type |
Description |
System.Boolean |
|
Type Parameters
Name |
Description |
AttributeType |
Attribute Type
|
HasAttribute<AttributeType>(MemberInfo, out AttributeType)
Returns True if the given member has at least one Attribute of the given attribute type.
Declaration
public static bool HasAttribute<AttributeType>(this MemberInfo memberInfo, out AttributeType attribute)
Parameters
Type |
Name |
Description |
MemberInfo |
memberInfo |
Member
|
AttributeType |
attribute |
Out parameter for attribute found
|
Returns
Type |
Description |
System.Boolean |
|
Type Parameters
Name |
Description |
AttributeType |
Attribute Type
|
HasAttribute<AttributeType>(Type)
Returns True if the given type has at least one Attribute of the given attribute type.
Declaration
public static bool HasAttribute<AttributeType>(this Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
Object Type
|
Returns
Type |
Description |
System.Boolean |
|
Type Parameters
Name |
Description |
AttributeType |
Attribute Type
|
IsIList(Type)
Returns true if the given type is of the type IList.
Declaration
public static bool IsIList(this Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
Returns
Type |
Description |
System.Boolean |
|
SetFieldValue<T>(Object, String, T)
Sets a field value from the property name and type using reflection.
Declaration
public static void SetFieldValue<T>(this object obj, string fieldName, T value)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
System.String |
fieldName |
|
T |
value |
|
Type Parameters
SetPropertyValue<T>(Object, String, T)
Sets a property value from the property name and type using reflection.
Declaration
public static void SetPropertyValue<T>(this object obj, string propertyName, T value)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
System.String |
propertyName |
|
T |
value |
|
Type Parameters