本文整理汇总了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;
}
示例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);
}
}