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


C# IAssemblyInfo.GetTypes方法代码示例

本文整理汇总了C#中IAssemblyInfo.GetTypes方法的典型用法代码示例。如果您正苦于以下问题:C# IAssemblyInfo.GetTypes方法的具体用法?C# IAssemblyInfo.GetTypes怎么用?C# IAssemblyInfo.GetTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAssemblyInfo的用法示例。


在下文中一共展示了IAssemblyInfo.GetTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTestCollectionDefinitions

        /// <summary>
        /// Gets the test collection definitions for the given assembly.
        /// </summary>
        /// <param name="assemblyInfo">The assembly.</param>
        /// <param name="messageAggregator">The message aggregator.</param>
        /// <returns>A list of mappings from test collection name to test collection definitions (as <see cref="ITypeInfo"/></returns>
        public static Dictionary<string, ITypeInfo> GetTestCollectionDefinitions(IAssemblyInfo assemblyInfo, IMessageAggregator messageAggregator)
        {
            var attributeTypesByName =
                assemblyInfo.GetTypes(false)
                        .Select(type => new { Type = type, Attribute = type.GetCustomAttributes(typeof(CollectionDefinitionAttribute).AssemblyQualifiedName).FirstOrDefault() })
                        .Where(list => list.Attribute != null)
                        .GroupBy(list => (string)list.Attribute.GetConstructorArguments().Single(),
                                 list => list.Type,
                                 StringComparer.OrdinalIgnoreCase);

            var result = new Dictionary<string, ITypeInfo>();

            foreach (var grouping in attributeTypesByName)
            {
                var types = grouping.ToList();
                result[grouping.Key] = types[0];

                if (types.Count > 1)
                    messageAggregator.Add(new EnvironmentalWarning
                    {
                        Message = String.Format("Multiple test collections declared with name '{0}': {1}",
                                                grouping.Key,
                                                String.Join(", ", types.Select(type => type.Name)))
                    });
            }

            return result;
        }
开发者ID:PKRoma,项目名称:xunit-codeplex,代码行数:34,代码来源:TestCollectionFactoryHelper.cs

示例2: PopulateChildrenImmediately

 /// <summary>
 /// Populates the children of the assembly test all at once.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The default implementation processes all public and non-public types within the assembly.
 /// </para>
 /// </remarks>
 /// <param name="assemblyScope">The assembly scope.</param>
 /// <param name="assembly">The assembly.</param>
 protected virtual void PopulateChildrenImmediately(IPatternScope assemblyScope, IAssemblyInfo assembly)
 {
     foreach (ITypeInfo type in assembly.GetTypes())
     {
         if (!type.IsNested)
             assemblyScope.Consume(type, false, DefaultTypePattern);
     }
 }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:18,代码来源:TestAssemblyPatternAttribute.cs


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