Show / Hide Table of Contents

Class MethodExtensions

Various extension methods for method reflection.

Inheritance
Object
MethodExtensions
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: DotNext.Reflection
Assembly: DotNext.dll
Syntax
public static class MethodExtensions

Methods

| Improve this Doc View Source

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

| Improve this Doc View Source

SignatureEquals(MethodBase, MethodBase, Boolean)

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.

Boolean respectCallingConvention

true to check calling convention; false to ignore calling convention.

Returns
Type Description
Boolean

true, if both methods have the same number of formal parameters and parameters are equal by type; otherwise, false.

| Improve this Doc View Source

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
Boolean

true, if the method parameters have the same set of types as types passed as array; otherwise, false.

| Improve this Doc View Source

SignatureEquals(MethodInfo, MethodInfo, Boolean)

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.

Boolean respectCallingConvention

true to check calling convention; false to ignore calling convention.

Returns
Type Description
Boolean

true, if both methods have the same number of formal parameters, parameters are equal by type and return types are equal; otherwise, false.

| Improve this Doc View Source

TryInvoke(MethodBase, Object, 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.

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