C# Class Microsoft.Silverlight.Testing.Harness.ReflectionUtility

A set of helper methods for interacting with methods and types that are marked with attributes.
Exibir arquivo Open project: garyjohnson/wpnest

Public Methods

Method Description
GetAssemblies ( ) : IList

Returns a list of unique assemblies from a set of types.

GetAssembliesFromInstances ( IEnumerable objects ) : IList

Retrieve a list of Reflection.Assembly types from a set of instances and/or types.

GetAttribute ( ITestMethod method, Type decoratingAttribute ) : Attribute

Given a test method and a decorative attribute of interest, retrieves a single Attribute instance. Will throw an exception if multiple attributes exist on the method.

GetAttribute ( ITestMethod method, Type decoratingAttribute, bool inherit ) : Attribute

Given a test method and a decorative attribute of interest, retrieves a single Attribute instance. Will throw an exception if multiple attributes exist on the method.

GetAttribute ( MemberInfo member, Type decoratingAttribute ) : Attribute

Given a method and a decorative attribute of interest, retrieves a single Attribute instance. Will throw an exception if multiple attributes exist on the method.

GetAttributes ( ITestMethod method, Type decoratingAttribute, bool inherit ) : ICollection

Given a test method, returns the attributes (if any) that are of the decoratingAttribute parameter's type.

GetAttributes ( MemberInfo member, Type decoratingAttribute ) : ICollection

Given a MethodInfo type, returns the attributes (if any) that are of the decoratingAttribute parameter's type.

GetAttributes ( MemberInfo member, Type decoratingAttribute, bool inherit ) : ICollection

Given a MethodInfo type, returns the attributes (if any) that are of the decoratingAttribute parameter's type.

GetMethodsWithAttribute ( Type type, Type decoratingAttribute ) : ICollection

Return a collection of MethodInfo instances given a type to look through and the attribute of interest.

GetOneMethodWithAttribute ( Type type, Type decoratingAttribute ) : MethodInfo

Retrieve a MethodInfo from a single decorated method inside a type, if any. Throws an Exception if there are > 1 methods that are decorated with the attribute.

GetTypesWithAttribute ( Assembly assembly, Type decoratingAttribute ) : ICollection

Retrieve all types in an assembly that are decorated with a specific attribute.

HasAttribute ( ITestMethod method, Type decoratingAttribute ) : bool

Returns a value indicating whether a method has the attribute.

HasAttribute ( MemberInfo member, Type decoratingAttribute ) : bool

Returns a value indicating whether a method has the attribute.

Private Methods

Method Description
GetAttribute ( ICollection attributes ) : Attribute

Given a list of attributes, retrieves a single Attribute instance. Will throw an exception if multiple attributes exist on the method.

Method Details

GetAssemblies() public static method

Returns a list of unique assemblies from a set of types.
public static GetAssemblies ( ) : IList
return IList

GetAssembliesFromInstances() public static method

Retrieve a list of Reflection.Assembly types from a set of instances and/or types.
public static GetAssembliesFromInstances ( IEnumerable objects ) : IList
objects IEnumerable Set of instances or types.
return IList

GetAttribute() public static method

Given a test method and a decorative attribute of interest, retrieves a single Attribute instance. Will throw an exception if multiple attributes exist on the method.
public static GetAttribute ( ITestMethod method, Type decoratingAttribute ) : Attribute
method ITestMethod ITestMethod instance.
decoratingAttribute System.Type /// Attribute type of interest. ///
return System.Attribute

GetAttribute() public static method

Given a test method and a decorative attribute of interest, retrieves a single Attribute instance. Will throw an exception if multiple attributes exist on the method.
public static GetAttribute ( ITestMethod method, Type decoratingAttribute, bool inherit ) : Attribute
method ITestMethod ITestMethod instance.
decoratingAttribute System.Type /// Attribute type of interest. ///
inherit bool A value indicating whether to look for custom /// inherited attributes.
return System.Attribute

GetAttribute() public static method

Given a method and a decorative attribute of interest, retrieves a single Attribute instance. Will throw an exception if multiple attributes exist on the method.
public static GetAttribute ( MemberInfo member, Type decoratingAttribute ) : Attribute
member System.Reflection.MemberInfo MemberInfo instance.
decoratingAttribute System.Type /// Attribute type of interest. ///
return System.Attribute

GetAttributes() public static method

Given a test method, returns the attributes (if any) that are of the decoratingAttribute parameter's type.
public static GetAttributes ( ITestMethod method, Type decoratingAttribute, bool inherit ) : ICollection
method ITestMethod ITestMethod instance.
decoratingAttribute System.Type Attribute of interest.
inherit bool Whether to inherit attributes.
return ICollection

GetAttributes() public static method

Given a MethodInfo type, returns the attributes (if any) that are of the decoratingAttribute parameter's type.
public static GetAttributes ( MemberInfo member, Type decoratingAttribute ) : ICollection
member System.Reflection.MemberInfo MemberInfo instance.
decoratingAttribute System.Type Attribute of interest.
return ICollection

GetAttributes() public static method

Given a MethodInfo type, returns the attributes (if any) that are of the decoratingAttribute parameter's type.
public static GetAttributes ( MemberInfo member, Type decoratingAttribute, bool inherit ) : ICollection
member System.Reflection.MemberInfo MemberInfo instance.
decoratingAttribute System.Type Attribute of interest.
inherit bool A value indicating whether to look for /// inheriting custom attributes.
return ICollection

GetMethodsWithAttribute() public static method

Return a collection of MethodInfo instances given a type to look through and the attribute of interest.
public static GetMethodsWithAttribute ( Type type, Type decoratingAttribute ) : ICollection
type System.Type Type to look through for methods.
decoratingAttribute System.Type Attribute of interest.
return ICollection

GetOneMethodWithAttribute() public static method

Retrieve a MethodInfo from a single decorated method inside a type, if any. Throws an Exception if there are > 1 methods that are decorated with the attribute.
public static GetOneMethodWithAttribute ( Type type, Type decoratingAttribute ) : MethodInfo
type System.Type Type of interest.
decoratingAttribute System.Type Attribute of interest.
return System.Reflection.MethodInfo

GetTypesWithAttribute() public static method

Retrieve all types in an assembly that are decorated with a specific attribute.
public static GetTypesWithAttribute ( Assembly assembly, Type decoratingAttribute ) : ICollection
assembly System.Reflection.Assembly Assembly to search.
decoratingAttribute System.Type /// Instance of the Type of attribute that marks interesting methods. ///
return ICollection

HasAttribute() public static method

Returns a value indicating whether a method has the attribute.
public static HasAttribute ( ITestMethod method, Type decoratingAttribute ) : bool
method ITestMethod ITestMethod instance.
decoratingAttribute System.Type Attribute of interest.
return bool

HasAttribute() public static method

Returns a value indicating whether a method has the attribute.
public static HasAttribute ( MemberInfo member, Type decoratingAttribute ) : bool
member System.Reflection.MemberInfo MemberInfo instance.
decoratingAttribute System.Type Attribute of interest.
return bool