Class ReflectionHelper
A set of functions to help with reflection, including referencing custom loaded DLLs by LemonEdge
Implements
Inherited Members
Namespace: LemonEdge.Utils
Assembly: LemonEdge.Utils.dll
Syntax
public class ReflectionHelper : IReflectionHelper
Constructors
ReflectionHelper()
Declaration
public ReflectionHelper()
Properties
CustomAssemblies
All custom assemblies dynamically loaded by LemonEdge through AddIn Modules
Declaration
public Assembly[] CustomAssemblies { get; }
Property Value
| Type | Description |
|---|---|
| Assembly[] |
GetBindingFlagForNonPublicAndPublic
Returns binding flags for finding properties/methods that are private and public
Declaration
public static BindingFlags GetBindingFlagForNonPublicAndPublic { get; }
Property Value
| Type | Description |
|---|---|
| BindingFlags |
Instance
Declaration
public static IReflectionHelper Instance { get; set; }
Property Value
| Type | Description |
|---|---|
| IReflectionHelper |
InvalidCustomAssemblies
List of custom assemblies that have not been correctly loaded
Declaration
public IEnumerable<(Assembly Assem, StringBuilder Reason)> InvalidCustomAssemblies { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<(Assembly Assem, StringBuilder Reason)> |
StandardAssemblies
All standard assemblies as part of the LemonEdge application
Declaration
public Assembly[] StandardAssemblies { get; }
Property Value
| Type | Description |
|---|---|
| Assembly[] |
Methods
AddAssembly(Assembly, Assembly)
Indicates the system has loaded a specified assembly into the LemonEdge app domain and it should be added to the
reflection cache, and can optionally replace any older version
Declaration
public void AddAssembly(Assembly assembly, Assembly replace = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | Add this assembly to the reflection cache |
| Assembly | replace | Replace this existing assembly in the reflection cache with the specified |
Remarks
This is used by the core LemonEdge system when loading custom addins. As users can change addins this allows the system to replace older versions with newr ones as they are updated.
GetAllDomainAssemblies()
Return all dlls loaded into the current domain. Excludes any dlls that have subsequently been unloaded.
Declaration
public IEnumerable<Assembly> GetAllDomainAssemblies()
Returns
| Type | Description |
|---|---|
| IEnumerable<Assembly> | A list of currently loaded assemblies, including custom LemonEdge AddIns that have been loaded |
GetAppInfo()
Returns the location and application name of the currently executing application
Declaration
public (string Path, string AppName) GetAppInfo()
Returns
| Type | Description |
|---|---|
| (string paramArguments, string queryFilter) | The location and application name of the currently executing application |
GetEnumTypes()
Returns a list of all Enum types in the system
Declaration
public IEnumerable<Type> GetEnumTypes()
Returns
| Type | Description |
|---|---|
| IEnumerable<Type> | A list of all Enums in the system |
GetNestedPropertyInfo(Type, string, string, bool)
Returns the PropertyInfo definition for the specified property against a property on this type. Given Entity.ParentProperty.NestedProperty, this returns NestedProperty's definition.
Declaration
public PropertyInfo GetNestedPropertyInfo(Type type, string parentPropertyName, string nestedPropertyName, bool throwIfMissing = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type that holds the specified property |
| string | parentPropertyName | The parent property that contains nestedPropertyName |
| string | nestedPropertyName | The property to return property info on |
| bool | throwIfMissing | Indicates if the property isn't found an ArgumentOutOfRangeException should be thrown, otherwise null is returned |
Returns
| Type | Description |
|---|---|
| PropertyInfo | The PropertyInfo for the specified |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If |
GetPropertyInfo(Type, string, bool)
Returns the PropertyInfo definition for the specified property against this type
Declaration
public PropertyInfo GetPropertyInfo(Type type, string propName, bool throwIfMissing = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type that holds the specified property |
| string | propName | The property to return property info on |
| bool | throwIfMissing | Indicates if the property isn't found an ArgumentOutOfRangeException should be thrown, otherwise null is returned |
Returns
| Type | Description |
|---|---|
| PropertyInfo | The PropertyInfo for the specified |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If |
GetTypeFromFullName(string)
Returns an instance of the type specified from the full name
Declaration
public Type GetTypeFromFullName(string fullName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fullName | The full name of a given type |
Returns
| Type | Description |
|---|---|
| Type | An instance of the type specified by its |
GetTypesInheritingFrom(Assembly, Type, bool)
Returns all types from the specified assembly that inherit the specified
type
Declaration
public IEnumerable<Type> GetTypesInheritingFrom(Assembly assembly, Type type, bool allowAbstract)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | The assembly to return matching types from |
| Type | type | The type to retrieve all other types that inherits from it |
| bool | allowAbstract | Indicates if abstract types are to be included in the result set or not |
Returns
| Type | Description |
|---|---|
| IEnumerable<Type> | A list of all types from the |
GetTypesInheritingFrom(Type, bool)
Returns all types that inherit from the specified type
Declaration
public IEnumerable<Type> GetTypesInheritingFrom(Type type, bool allowAbstract)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type to retrieve all other types that inherits from it |
| bool | allowAbstract | Indicates if abstract types are to be included in the result set or not |
Returns
| Type | Description |
|---|---|
| IEnumerable<Type> | A list of all types that inherit from |
GetTypesInheritingFrom<T>(bool)
Returns all types that inherit from the specified type T
Declaration
public IEnumerable<Type> GetTypesInheritingFrom<T>(bool allowAbstract)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | allowAbstract | Indicates if abstract types are to be included in the result set or not |
Returns
| Type | Description |
|---|---|
| IEnumerable<Type> | A list of all types that inherit from |
Type Parameters
| Name | Description |
|---|---|
| T | The type to retrieve all other types that inherits from it |
GetTypesWithAttribute<T>(bool)
Returns a list of all types in the system that are marked with the specified attribute
Declaration
public IEnumerable<(T AttributeInstance, Type Type)> GetTypesWithAttribute<T>(bool inherit = false) where T : Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| bool | inherit | Indicates that a type should be included if the attribute is marked against its base type and not just itself |
Returns
| Type | Description |
|---|---|
| IEnumerable<(T AttributeInstance, Type Type)> | A tuple list containing the attribute |
Type Parameters
| Name | Description |
|---|---|
| T | The attribute type to find all types that are marked with it |
LoadAssemblies(Func<AssemblyName, Assembly, bool>)
Loads all the assemblies in the current domain (and dependencies) matching the predicate
Declaration
public Assembly[] LoadAssemblies(Func<AssemblyName, Assembly, bool> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<AssemblyName, Assembly, bool> | predicate | The predicate filter. |
Returns
| Type | Description |
|---|---|
| Assembly[] | The matched and loaded assemblies. |
TypeFromInterface<T>()
Declaration
public static Type TypeFromInterface<T>()
Returns
| Type | Description |
|---|---|
| Type |
Type Parameters
| Name | Description |
|---|---|
| T |