当前位置: 首页>>代码示例>>C#>>正文


C# IMethodInfo.GetAttributeInfos方法代码示例

本文整理汇总了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;
         }
     }
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:60,代码来源:MSTestExplorer.cs


注:本文中的IMethodInfo.GetAttributeInfos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。