本文整理汇总了C#中ITestMethod.GetDynamicAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# ITestMethod.GetDynamicAttributes方法的具体用法?C# ITestMethod.GetDynamicAttributes怎么用?C# ITestMethod.GetDynamicAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITestMethod
的用法示例。
在下文中一共展示了ITestMethod.GetDynamicAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAttributes
/// <summary>
/// Given a test method, returns the attributes (if any) that are of
/// the decoratingAttribute parameter's type.
/// </summary>
/// <param name="method">ITestMethod instance.</param>
/// <param name="decoratingAttribute">Attribute of interest.</param>
/// <param name="inherit">Whether to inherit attributes.</param>
/// <returns>
/// A collection populated with the Attribute instances.
/// </returns>
public static ICollection<Attribute> GetAttributes(ITestMethod method, Type decoratingAttribute, bool inherit)
{
if (method == null)
{
throw new ArgumentNullException("method");
}
else if (decoratingAttribute == null)
{
throw new ArgumentNullException("decoratingAttribute");
}
// Get the attributes defined on the method
ICollection<Attribute> attributes = GetAttributes(method.Method, decoratingAttribute, inherit);
// Get any dynamic attributes for the method
IEnumerable<Attribute> dynamicAttributes = method.GetDynamicAttributes();
if (dynamicAttributes != null)
{
foreach (Attribute attribute in dynamicAttributes)
{
if (decoratingAttribute.IsAssignableFrom(attribute.GetType()))
{
attributes.Add(attribute);
}
}
}
return attributes;
}