Class ReflectionInvoker
Provides generic, overload-resolving reflection helpers for invoking static and instance methods with defensive error handling.
Inheritance
Inherited Members
Namespace: WizardWrx.Core
Assembly: WizardWrx.Core.dll
Syntax
public static class ReflectionInvoker
Methods
| Improve this Doc View SourceInvokeInstanceMethod<T>(String, String, String, Object, Object[], BindingFlags)
Invoke an instance method by name, resolving overloads based on argument types, and return its result as the specified generic type.
Declaration
public static T InvokeInstanceMethod<T>(string pstrAssemblyPath, string pstrFullyQualifiedTypeName, string pstrMethodName, object pobjInstance, object[] paobjParameters, BindingFlags penmFlagsBitMask = BindingFlags.Instance | BindingFlags.Public)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | pstrAssemblyPath | Absolute path to the DLL containing the type. |
| System.String | pstrFullyQualifiedTypeName | Namespace-qualified type name. |
| System.String | pstrMethodName | Name of the instance method to invoke. |
| System.Object | pobjInstance | Instance of the type on which to invoke the method. |
| System.Object[] | paobjParameters | Arguments to pass to the method. |
| System.Reflection.BindingFlags | penmFlagsBitMask | Binding penmFlagsBitMask (defaults to Public | Instance). |
Returns
| Type | Description |
|---|---|
| T | Result of the method call, cast to |
Type Parameters
| Name | Description |
|---|---|
| T | Expected return type. |
InvokeMethod(Object, String, BindingFlags, Object[])
Invokes a method (virtual, non-virtual, or overridden) on the given target object.
Declaration
public static object InvokeMethod(object pobjTarget, string pstrMethodName, BindingFlags penmBindingFlagsBitMask, params object[] paobjParameters)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | pobjTarget | This required generic object represents the instance on which to invoke
method |
| System.String | pstrMethodName | This string represents the name of the method on object
|
| System.Reflection.BindingFlags | penmBindingFlagsBitMask | This bit mask represents one or more members of the BindingFlags enumeration. |
| System.Object[] | paobjParameters | This optional array of generic objects is the parameters for the method, if any. Since it is a parameter array, this argument is, and must be, last. |
Returns
| Type | Description |
|---|---|
| System.Object | This generic object is the return value of the method, or null if the method returns void. |
InvokeStaticMethod<T>(String, String, String, Object[], BindingFlags)
Invoke a static method by name, resolving overloads based on argument types, and return its result as the specified generic type.
Declaration
public static T InvokeStaticMethod<T>(string pstrAssemblyPath, string pstrFullyQualifiedTypeName, string pstrMethodName, object[] paobjParameters, BindingFlags penmFlagsBitMask = BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | pstrAssemblyPath | Absolute path to the DLL containing the type. |
| System.String | pstrFullyQualifiedTypeName | Namespace-qualified type name. |
| System.String | pstrMethodName | Name of the static method to invoke. |
| System.Object[] | paobjParameters | Arguments to pass to the method. |
| System.Reflection.BindingFlags | penmFlagsBitMask | Binding penmFlagsBitMask (defaults to Public | Static | BindingFlags.FlattenHierarchy). |
Returns
| Type | Description |
|---|---|
| T | Result of the method call, cast to |
Type Parameters
| Name | Description |
|---|---|
| T | Expected return type. |