Class TypeWrapper
The TypeWrapper class wraps a Type so it may be used in a platform-independent manner.
public class TypeWrapper : ITypeInfo, IReflectionInfo
- Inheritance
-
TypeWrapper
- Implements
- Inherited Members
Constructors
TypeWrapper(Type)
Construct a TypeWrapper for a specified Type.
public TypeWrapper(Type type)
Parameters
type
Type
Properties
Assembly
Gets the assembly in which the type is declared
public Assembly Assembly { get; }
Property Value
BaseType
Gets the base type of this type as an ITypeInfo
public ITypeInfo? BaseType { get; }
Property Value
ContainsGenericParameters
Gets a value indicating whether the Type has generic parameters that have not been replaced by specific Types.
public bool ContainsGenericParameters { get; }
Property Value
FullName
Gets the FullName of the Type
public string FullName { get; }
Property Value
IsAbstract
Gets a value indicating whether the type is abstract.
public bool IsAbstract { get; }
Property Value
IsGenericType
Gets a value indicating whether the Type is a generic Type
public bool IsGenericType { get; }
Property Value
IsGenericTypeDefinition
Gets a value indicating whether the Type is a generic Type definition
public bool IsGenericTypeDefinition { get; }
Property Value
IsSealed
Gets a value indicating whether the type is sealed.
public bool IsSealed { get; }
Property Value
IsStaticClass
Gets a value indicating whether this type represents a static class.
public bool IsStaticClass { get; }
Property Value
Name
Gets the Name of the Type
public string Name { get; }
Property Value
Namespace
Gets the namespace of the Type
public string? Namespace { get; }
Property Value
Type
Gets the underlying Type on which this TypeWrapper is based.
public Type Type { get; }
Property Value
Methods
Construct(object?[]?)
Construct an object of this Type, using the specified arguments.
public object Construct(object?[]? args)
Parameters
args
object[]
Returns
GetConstructor(Type[])
Gets the public constructor taking the specified argument Types
public ConstructorInfo? GetConstructor(Type[] argTypes)
Parameters
argTypes
Type[]
Returns
GetCustomAttributes<T>(bool)
Returns an array of custom attributes of the specified type applied to this type
public T[] GetCustomAttributes<T>(bool inherit) where T : class
Parameters
inherit
bool
Returns
- T[]
Type Parameters
T
GetDisplayName()
Get the display name for this type
public string GetDisplayName()
Returns
GetDisplayName(object?[]?)
Get the display name for an object of this type, constructed with the specified args.
public string GetDisplayName(object?[]? args)
Parameters
args
object[]
Returns
GetGenericTypeDefinition()
Returns a Type representing a generic type definition from which this Type can be constructed.
public Type GetGenericTypeDefinition()
Returns
GetMethods(BindingFlags)
Returns an array of IMethodInfos for methods of this Type that match the specified flags.
public IMethodInfo[] GetMethods(BindingFlags flags)
Parameters
flags
BindingFlags
Returns
GetMethodsWithAttribute<T>(bool)
Returns all methods declared by this type that have the specified attribute, optionally including base classes. Methods from a base class are always returned before methods from a class that inherits from it.
public IMethodInfo[] GetMethodsWithAttribute<T>(bool inherit) where T : class
Parameters
inherit
boolSpecifies whether to search the fixture type inheritance chain.
Returns
Type Parameters
T
HasConstructor(Type[])
Returns a value indicating whether this Type has a public constructor taking the specified argument Types.
public bool HasConstructor(Type[] argTypes)
Parameters
argTypes
Type[]
Returns
HasMethodWithAttribute(Type)
Returns a flag indicating whether this type has a method with an attribute of the specified type.
public bool HasMethodWithAttribute(Type attributeType)
Parameters
attributeType
Type
Returns
IsDefined<T>(bool)
Returns a value indicating whether the type has an attribute of the specified type.
public bool IsDefined<T>(bool inherit) where T : class
Parameters
inherit
bool
Returns
Type Parameters
T
IsType(Type)
Returns true if the Type wrapped is T
public bool IsType(Type type)
Parameters
type
Type
Returns
MakeGenericType(Type[])
Returns a new ITypeInfo representing an instance of this generic Type using the supplied Type arguments
public ITypeInfo MakeGenericType(Type[] typeArgs)
Parameters
typeArgs
Type[]
Returns
ToString()
Override ToString() so that error messages in NUnit's own tests make sense
public override string ToString()