Class ReflectionExtensions
Reflection related extension methods.
Namespace: Neon.Common
Assembly: Neon.Common.dll
Syntax
public static class ReflectionExtensions
Methods
GetParameterTypes(MethodInfo)
Returns the array of types for a method's parameters.
Declaration
public static Type[] GetParameterTypes(this MethodInfo method)
Parameters
Type | Name | Description |
---|---|---|
MethodInfo | method | The method. |
Returns
Type | Description |
---|---|
Type[] | The parameter type array. |
Implements(Type, Type)
Determines whether a Type implements a specific interface.
Declaration
public static bool Implements(Type type, Type interfaceType)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type being tested. |
Type | interfaceType | The interface type. |
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if either of |
ArgumentException | Thrown if |
Implements<TInterface>(Type)
Determines whether a Type implements a specific interface.
Declaration
public static bool Implements<TInterface>(this Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type being tested. |
Returns
Type | Description |
---|---|
bool |
|
Type Parameters
Name | Description |
---|---|
TInterface | The required interface type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentException | Thrown if |
Inherits<TBase>(Type)
Determines whether a type inherits from another type.
Declaration
public static bool Inherits<TBase>(this Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type being tested. |
Returns
Type | Description |
---|---|
bool |
|
Type Parameters
Name | Description |
---|---|
TBase | The required base type. |
Remarks
note
This method also returns true
when TBase
is the
same as type
.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
Is(Type, Type)
Determines whether a type inherits from (or is) a specified base type.
Declaration
public static bool Is(this Type type, Type targetType)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type being tested. |
Type | targetType | Identifies the type we're matching. |
Returns
Type | Description |
---|---|
bool |
|
Is<T>(Type)
Determines whether a type inherits from (or is) a specified base type.
Declaration
public static bool Is<T>(this Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type being tested. |
Returns
Type | Description |
---|---|
bool |
|
Type Parameters
Name | Description |
---|---|
T | Identifies the type we're matching. |