本文整理汇总了C#中IMethodInfo.GetAttributeInfos方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodInfo.GetAttributeInfos方法的具体用法?C# IMethodInfo.GetAttributeInfos怎么用?C# IMethodInfo.GetAttributeInfos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodInfo
的用法示例。
在下文中一共展示了IMethodInfo.GetAttributeInfos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateTestMethodMetadata
private static void PopulateTestMethodMetadata(IMethodInfo methodInfo, MSTest methodTest)
{
IEnumerable<IAttributeInfo> attributes = methodInfo.GetAttributeInfos(null, true);
foreach (IAttributeInfo attribute in attributes)
{
switch (attribute.Type.FullName)
{
case MSTestAttributes.AspNetDevelopmentServerAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.AspNetDevelopmentServer, GetAspNetDevelopmentServer(attribute));
break;
case MSTestAttributes.AspNetDevelopmentServerHostAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.AspNetDevelopmentServerHost, GetAspNetDevelopmentServerHost(attribute));
break;
case MSTestAttributes.CredentialAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.Credential, GetCredential(attribute));
break;
case MSTestAttributes.CssIterationAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.CssIteration, GetAttributePropertyValue(attribute, MSTestMetadataKeys.CssIteration));
break;
case MSTestAttributes.CssProjectStructureAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.CssProjectStructure, GetAttributePropertyValue(attribute, MSTestMetadataKeys.CssProjectStructure));
break;
case MSTestAttributes.DeploymentItemAttribute:
AddDeploymentItem(attribute, methodTest);
break;
case MSTestAttributes.DataSourceAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.DataSource, GetDatasource(attribute));
break;
case MSTestAttributes.DescriptionAttribute:
methodTest.Metadata.Add(MetadataKeys.Description, GetAttributePropertyValue(attribute, MetadataKeys.Description));
break;
case MSTestAttributes.HostTypeAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.HostType, GetHostType(attribute));
break;
case MSTestAttributes.IgnoreAttribute:
methodTest.Metadata.Add(MetadataKeys.IgnoreReason, Resources.MSTestExplorer_IgnoreAttributeWasAppliedToTest);
break;
case MSTestAttributes.OwnerAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.Owner, GetAttributePropertyValue(attribute, MSTestMetadataKeys.Owner));
break;
case MSTestAttributes.PriorityAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.Priority, GetAttributePropertyValue(attribute, MSTestMetadataKeys.Priority));
break;
case MSTestAttributes.TestPropertyAttribute:
AddTestProperty(attribute, methodTest);
break;
case MSTestAttributes.TimeoutAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.Timeout, GetAttributePropertyValue(attribute, MSTestMetadataKeys.Timeout));
break;
case MSTestAttributes.UrlToTestAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.UrlToTest, GetAttributePropertyValue(attribute, MSTestMetadataKeys.UrlToTest));
break;
case MSTestAttributes.WorkItemAttribute:
methodTest.Metadata.Add(MSTestMetadataKeys.WorkItem, GetAttributePropertyValue(attribute, "Id"));
break;
default:
break;
}
}
}