本文整理汇总了C#中ITypeInfo.IsType方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeInfo.IsType方法的具体用法?C# ITypeInfo.IsType怎么用?C# ITypeInfo.IsType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeInfo
的用法示例。
在下文中一共展示了ITypeInfo.IsType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFixtureBuilderAttributes
/// <summary>
/// We look for attributes implementing IFixtureBuilder at one level
/// of inheritance at a time. Attributes on base classes are not used
/// unless there are no fixture builder attributes at all on the derived
/// class. This is by design.
/// </summary>
/// <param name="typeInfo">The type being examined for attributes</param>
/// <returns>A list of the attributes found.</returns>
private IFixtureBuilder[] GetFixtureBuilderAttributes(ITypeInfo typeInfo)
{
IFixtureBuilder[] attrs = new IFixtureBuilder[0];
while (typeInfo != null && !typeInfo.IsType(typeof(object)))
{
attrs = typeInfo.GetCustomAttributes<IFixtureBuilder>(false);
if (attrs.Length > 0)
{
// We want to eliminate duplicates that have no args.
// If there is just one, no duplication is possible.
if (attrs.Length == 1)
return attrs;
// Count how many have arguments
int withArgs = 0;
foreach (var attr in attrs)
if (HasArguments(attr))
withArgs++;
// If all have args, just return them
if (withArgs == attrs.Length)
return attrs;
// If none of them have args, return the first one
if (withArgs == 0)
return new IFixtureBuilder[] { attrs[0] };
// Some of each - extract those with args
var result = new IFixtureBuilder[withArgs];
int count = 0;
foreach (var attr in attrs)
if (HasArguments(attr))
result[count++] = attr;
return result;
}
typeInfo = typeInfo.BaseType;
}
return attrs;
}