Class MethodExtensions
Various extension methods for method reflection.
Inherited Members
Namespace: DotNext.Reflection
Assembly: DotNext.dll
Syntax
public static class MethodExtensions
Methods
| Edit this page View SourceGetParameterTypes(MethodBase?)
Returns method parameter types respecting order of parameters.
Declaration
public static Type[]? GetParameterTypes(this MethodBase? method)
Parameters
Type | Name | Description |
---|---|---|
MethodBase | method | The method to reflect. |
Returns
Type | Description |
---|---|
Type[] | The array of parameter types. |
SignatureEquals(MethodBase, MethodBase, bool)
Determines whether formal parameters of both methods are equal by type.
Declaration
public static bool SignatureEquals(this MethodBase method, MethodBase other, bool respectCallingConvention = false)
Parameters
Type | Name | Description |
---|---|---|
MethodBase | method | The first method to compare. |
MethodBase | other | The second method to compare. |
bool | respectCallingConvention | true to check calling convention; false to ignore calling convention. |
Returns
Type | Description |
---|---|
bool | true, if both methods have the same number of formal parameters and parameters are equal by type; otherwise, false. |
SignatureEquals(MethodBase, Type[])
Determines whether the method parameters have the same set of types as in given array of types.
Declaration
public static bool SignatureEquals(this MethodBase method, Type[] parameters)
Parameters
Type | Name | Description |
---|---|---|
MethodBase | method | The method to check. |
Type[] | parameters | The expected parameter types. |
Returns
Type | Description |
---|---|
bool | true, if the method parameters have the same set of types as types passed as array; otherwise, false. |
SignatureEquals(MethodInfo, MethodInfo, bool)
Determines whether formal parameters of both methods are equal by type and return types are also equal.
Declaration
public static bool SignatureEquals(this MethodInfo method, MethodInfo other, bool respectCallingConvention = false)
Parameters
Type | Name | Description |
---|---|---|
MethodInfo | method | The first method to compare. |
MethodInfo | other | The second method to compare. |
bool | respectCallingConvention | true to check calling convention; false to ignore calling convention. |
Returns
Type | Description |
---|---|
bool | true, if both methods have the same number of formal parameters, parameters are equal by type and return types are equal; otherwise, false. |
TryInvoke(MethodBase, object?, params object?[])
Invokes the method or constructor represented by the current instance, using the specified arguments.
Declaration
public static Result<object?> TryInvoke(this MethodBase method, object? obj, params object?[] args)
Parameters
Type | Name | Description |
---|---|---|
MethodBase | method | The method or constructor to invoke. |
object | obj | The object on which to invoke the method or constructor. If a method is static, this argument is ignored. If a constructor is static, this argument must be null or an instance of the class that defines the constructor. |
object[] | args | An argument list for the invoked method or constructor. |
Returns
Type | Description |
---|---|
Result<object> | An object containing the return value of the invoked method, or null in the case of a constructor. |
Remarks
This method never throws an exception. Examine IsSuccessful or Error instead.