Show / Hide Table of Contents

Class ReflectionHelper

Helper class for reflection.

Inheritance
System.Object
ReflectionHelper
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Kephas.Reflection
Assembly: Kephas.Core.dll
Syntax
public static class ReflectionHelper

Properties

| Improve this Doc View Source

IsSystemAssemblyFunc

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 Source

AsRuntimeAssemblyInfo(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

true if the assembly is a system assembly, false if not.

| Improve this Doc View Source

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

true if the assembly is a system assembly, false if not.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX