Class TypeHelper
TypeHelper provides static methods that operate on Types.
public static class TypeHelper
- Inheritance
-
TypeHelper
- Inherited Members
Methods
CanDeduceTypeArgsFromArgs(Type, object?[], ref Type[]?)
Determines whether this instance can deduce type args for a generic type from the supplied arguments.
public static bool CanDeduceTypeArgsFromArgs(Type type, object?[] arglist, ref Type[]? typeArgsOut)
Parameters
type
TypeThe type to be examined.
arglist
object[]The arglist.
typeArgsOut
Type[]The type args to be used.
Returns
- bool
true if this the provided args give sufficient information to determine the type args to be used; otherwise, false.
ConvertArgumentList(object?[], IParameterInfo[])
Convert an argument list to the required parameter types. Currently, only widening numeric conversions are performed.
public static void ConvertArgumentList(object?[] arglist, IParameterInfo[] parameters)
Parameters
arglist
object[]An array of args to be converted
parameters
IParameterInfo[]A ParameterInfo[] whose types will be used as targets
GetDeclaredInterfaces(Type)
Return the interfaces implemented by a Type.
public static Type[] GetDeclaredInterfaces(Type type)
Parameters
type
TypeThe Type to be examined.
Returns
- Type[]
An array of Types for the interfaces.
GetDisplayName(Type)
Gets the display name for a Type as used by NUnit.
public static string GetDisplayName(Type type)
Parameters
type
TypeThe Type for which a display name is needed.
Returns
- string
The display name for the Type
GetDisplayName(Type, object?[]?)
Gets the display name for a Type as used by NUnit.
public static string GetDisplayName(Type type, object?[]? arglist)
Parameters
Returns
- string
The display name for the Type
IsNumeric(Type)
Determines whether the specified type is numeric.
public static bool IsNumeric(Type type)
Parameters
type
TypeThe type to be examined.
Returns
IsTuple(Type)
Return whether or not the given type is a Tuple.
public static bool IsTuple(Type type)
Parameters
type
TypeType.
Returns
- bool
Whether or not the given type is a Tuple.
IsValueTuple(Type)
Return whether or not the given type is a ValueTuple.
public static bool IsValueTuple(Type type)
Parameters
type
TypeType.
Returns
- bool
Whether or not the given type is a ValueTuple.
TryGetBestCommonType(Type?, Type?, out Type?)
Returns the best fit for a common type to be used in matching actual arguments to a methods Type parameters.
public static bool TryGetBestCommonType(Type? type1, Type? type2, out Type? bestCommonType)