Class ReflectionHelper
Helper class for reflection.
Inheritance
Inherited Members
Namespace: Kephas.Reflection
Assembly: Kephas.Core.dll
Syntax
public static class ReflectionHelper
Properties
| Improve this Doc View SourceIsSystemAssemblyFunc
Gets or sets the function to check whether an assembly is a system assembly.
Declaration
public static Func<AssemblyName, bool> IsSystemAssemblyFunc { get; set; }
Property Value
Type | Description |
---|---|
System.Func<System.Reflection.AssemblyName, System.Boolean> | A function delegate that yields a bool. |
Methods
| Improve this Doc View SourceAsRuntimeAssemblyInfo(Assembly)
Gets the IRuntimeAssemblyInfo for the provided System.Reflection.Assembly instance.
Declaration
public static IRuntimeAssemblyInfo AsRuntimeAssemblyInfo(this Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The assembly. |
Returns
Type | Description |
---|---|
IRuntimeAssemblyInfo | The provided System.Reflection.Assembly's associated IRuntimeAssemblyInfo. |
Call(MethodInfo, Object, Object[])
Invokes the methodInfo
with the provided parameters,
ensuring in case of an exception that the original exception is thrown.
Declaration
public static object Call(this MethodInfo methodInfo, object instance, params object[] arguments)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MethodInfo | methodInfo | The method information. |
System.Object | instance | The instance. |
System.Object[] | arguments | A variable-length parameters list containing arguments. |
Returns
Type | Description |
---|---|
System.Object | The invocation result. |
CreateStaticDelegate<T>(MethodInfo)
Creates the static delegate for the provided static method.
Declaration
public static T CreateStaticDelegate<T>(this MethodInfo methodInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MethodInfo | methodInfo | The method information. |
Returns
Type | Description |
---|---|
T | A static delegate for the provided static method. |
Type Parameters
Name | Description |
---|---|
T | The delegate type. |
GetAssemblyQualifiedShortName(Type)
Gets the assembly qualified name without the version and public key information.
Declaration
public static string GetAssemblyQualifiedShortName(this Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type. |
Returns
Type | Description |
---|---|
System.String | The assembly qualified name without the version and public key information. |
GetFilePath(Assembly)
Gets the file path to the loaded assembly.
Declaration
public static string GetFilePath(this Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The assembly. |
Returns
Type | Description |
---|---|
System.String | The file path of the loaded assembly. |
GetGenericMethodOf(Expression)
Gets the generic method indicated by the given expression. The given expression must be a lambda expression.
Declaration
public static MethodInfo GetGenericMethodOf(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Reflection.MethodInfo | A System.Reflection.MethodInfo. |
GetGenericMethodOf<TReturn>(Expression<Func<Object, TReturn>>)
Gets the generic method indicated by the given expression. The given expression must be a lambda expression.
Declaration
public static MethodInfo GetGenericMethodOf<TReturn>(Expression<Func<object, TReturn>> expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<System.Object, TReturn>> | expression | The expression. |
Returns
Type | Description |
---|---|
System.Reflection.MethodInfo | A System.Reflection.MethodInfo. |
Type Parameters
Name | Description |
---|---|
TReturn | The type of the return. |
GetLocation(Assembly)
Gets the location for the provided assembly.
Declaration
public static string GetLocation(this Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The assembly to be checked. |
Returns
Type | Description |
---|---|
System.String | The assembly location. |
GetMethodOf(Expression)
Gets the method indicated by the given expression. The given expression must be a lambda expression.
Declaration
public static MethodInfo GetMethodOf(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | The expression. |
Returns
Type | Description |
---|---|
System.Reflection.MethodInfo | A System.Reflection.MethodInfo. |
GetMethodOf<TReturn>(Expression<Func<Object, TReturn>>)
Gets the method indicated by the given expression. The given expression must be a lambda expression.
Declaration
public static MethodInfo GetMethodOf<TReturn>(Expression<Func<object, TReturn>> expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<System.Object, TReturn>> | expression | The expression. |
Returns
Type | Description |
---|---|
System.Reflection.MethodInfo | A System.Reflection.MethodInfo. |
Type Parameters
Name | Description |
---|---|
TReturn | The type of the return. |
GetNonGenericFullName(TypeInfo)
Gets the full name of the non generic type with the same base name as the provided type.
Declaration
public static string GetNonGenericFullName(this TypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.TypeInfo | typeInfo | The type information. |
Returns
Type | Description |
---|---|
System.String | The full name of the non generic type. |
GetNonGenericFullName(Type)
Gets the full name of the non generic type with the same base name as the provided type.
Declaration
public static string GetNonGenericFullName(this Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type. |
Returns
Type | Description |
---|---|
System.String | The full name of the non generic type. |
GetPropertyName<T>(Expression<Func<T, Object>>)
Retrieves the property name from a lambda expression.
Declaration
public static string GetPropertyName<T>(Expression<Func<T, object>> expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, System.Object>> | expression | The property expression. |
Returns
Type | Description |
---|---|
System.String | The property name. |
Type Parameters
Name | Description |
---|---|
T | The type from which the property name is extracted. |
GetPropertyName<T, TValue>(Expression<Func<T, TValue>>)
Retrieves the property name from a lambda expression.
Declaration
public static string GetPropertyName<T, TValue>(Expression<Func<T, TValue>> expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, TValue>> | expression | The property expression. |
Returns
Type | Description |
---|---|
System.String | The property name. |
Type Parameters
Name | Description |
---|---|
T | The type from which the property name is extracted. |
TValue | The type of the value. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Expected property expression. |
GetStaticPropertyName(Expression<Func<Object>>)
Retrieves the property name from a lambda expression.
Declaration
public static string GetStaticPropertyName(Expression<Func<object>> expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<System.Object>> | expression | The property expression. |
Returns
Type | Description |
---|---|
System.String | The property name. |
GetTypeInfo(Object)
Gets the most specific type information out of the provided instance. If the object implements IInstance, then it returns the ITypeInfo provided by it, otherwise it returns the IRuntimeTypeInfo of its runtime type.
Declaration
public static ITypeInfo GetTypeInfo(this object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object. |
Returns
Type | Description |
---|---|
ITypeInfo | A type information for the provided object. |
IsPrivate(String)
Indicates whether the identifier is private.
Declaration
public static bool IsPrivate(this string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The identifier to act on. |
Returns
Type | Description |
---|---|
System.Boolean | True if the identifier is private, false if not. |
IsSystemAssembly(Assembly)
Gets a value indicating whether the provided assembly is a system assembly.
Declaration
public static bool IsSystemAssembly(this Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The assembly to be checked. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsSystemAssembly(AssemblyName)
Gets a value indicating whether the provided assembly is a system assembly.
Declaration
public static bool IsSystemAssembly(this AssemblyName assemblyName)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.AssemblyName | assemblyName | The assembly to be checked. |
Returns
Type | Description |
---|---|
System.Boolean |
|