IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
NUnit.Framework.Internal.Reflect Class Reference

Helper methods for inspecting a type by reflection. More...

Classes

class  BaseTypesFirstComparer
 

Static Public Member Functions

static MethodInfo[] GetMethodsWithAttribute (Type fixtureType, Type attributeType, bool inherit)
 Examine a fixture type and return an array of methods having a particular attribute. The array is order with base methods first. More...
 
static bool HasMethodWithAttribute (Type fixtureType, Type attributeType)
 Examine a fixture type and return true if it has a method with a particular attribute. More...
 
static object Construct (Type type)
 Invoke the default constructor on a Type More...
 
static object Construct (Type type, object[] arguments)
 Invoke a constructor on a Type with arguments More...
 
static object InvokeMethod (MethodInfo method, object fixture)
 Invoke a parameterless method returning void on an object. More...
 
static object InvokeMethod (MethodInfo method, object fixture, params object[] args)
 Invoke a method, converting any TargetInvocationException to an NUnitException. More...
 

Static Private Member Functions

static Type[] GetTypeArray (object[] objects)
 Returns an array of types from an array of objects. Used because the compact framework doesn't support Type.GetTypeArray() More...
 

Static Private Attributes

static readonly BindingFlags AllMembers = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static
 
static readonly Type[] EmptyTypes = new Type[0]
 

Detailed Description

Helper methods for inspecting a type by reflection.

Many of these methods take ICustomAttributeProvider as an argument to avoid duplication, even though certain attributes can only appear on specific types of members, like MethodInfo or Type.

In the case where a type is being examined for the presence of an attribute, interface or named member, the Reflect methods operate with the full name of the member being sought. This removes the necessity of the caller having a reference to the assembly that defines the item being sought and allows the NUnit core to inspect assemblies that reference an older version of the NUnit framework.

Member Function Documentation

static MethodInfo [] NUnit.Framework.Internal.Reflect.GetMethodsWithAttribute ( Type  fixtureType,
Type  attributeType,
bool  inherit 
)
inlinestatic

Examine a fixture type and return an array of methods having a particular attribute. The array is order with base methods first.

Parameters
fixtureTypeThe type to examine
attributeTypeThe attribute Type to look for
inheritSpecifies whether to search the fixture type inheritance chain
Returns
The array of methods found

Referenced by NUnit.Framework.Internal.Execution.CommandBuilder.BuildSetUpTearDownList(), and NUnit.Framework.Internal.TestSuite.CheckSetUpTearDownMethods().

static bool NUnit.Framework.Internal.Reflect.HasMethodWithAttribute ( Type  fixtureType,
Type  attributeType 
)
inlinestatic

Examine a fixture type and return true if it has a method with a particular attribute.

Parameters
fixtureTypeThe type to examine
attributeTypeThe attribute Type to look for
Returns
True if found, otherwise false

Referenced by NUnit.Framework.Internal.TypeWrapper.HasMethodWithAttribute().

static object NUnit.Framework.Internal.Reflect.Construct ( Type  type,
object[]  arguments 
)
inlinestatic

Invoke a constructor on a Type with arguments

Parameters
typeThe Type to be constructed
argumentsArguments to the constructor
Returns
An instance of the Type
static Type [] NUnit.Framework.Internal.Reflect.GetTypeArray ( object[]  objects)
inlinestaticprivate

Returns an array of types from an array of objects. Used because the compact framework doesn't support Type.GetTypeArray()

Parameters
objectsAn array of objects
Returns
An array of Types
static object NUnit.Framework.Internal.Reflect.InvokeMethod ( MethodInfo  method,
object  fixture 
)
inlinestatic

Invoke a parameterless method returning void on an object.

Parameters
methodA MethodInfo for the method to be invoked
fixtureThe object on which to invoke the method

Referenced by NUnit.Framework.Internal.MethodWrapper.Invoke(), and NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunNonAsyncMethod().

static object NUnit.Framework.Internal.Reflect.InvokeMethod ( MethodInfo  method,
object  fixture,
params object[]  args 
)
inlinestatic

Invoke a method, converting any TargetInvocationException to an NUnitException.

Parameters
methodA MethodInfo for the method to be invoked
fixtureThe object on which to invoke the method
argsThe argument list for the method
Returns
The return value from the invoked method

Member Data Documentation

readonly BindingFlags NUnit.Framework.Internal.Reflect.AllMembers = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static
staticprivate
readonly Type [] NUnit.Framework.Internal.Reflect.EmptyTypes = new Type[0]
staticprivate

The documentation for this class was generated from the following file: