本文整理汇总了C#中ITypeInfo.IsDefined方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeInfo.IsDefined方法的具体用法?C# ITypeInfo.IsDefined怎么用?C# ITypeInfo.IsDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeInfo
的用法示例。
在下文中一共展示了ITypeInfo.IsDefined方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanBuildFrom
/// <summary>
/// Checks to see if the provided Type is a fixture.
/// To be considered a fixture, it must be a non-abstract
/// class with one or more attributes implementing the
/// IFixtureBuilder interface or one or more methods
/// marked as tests.
/// </summary>
/// <param name="typeInfo">The fixture type to check</param>
/// <returns>True if the fixture can be built, false if not</returns>
public bool CanBuildFrom(ITypeInfo typeInfo)
{
if (typeInfo.IsAbstract && !typeInfo.IsSealed)
return false;
if (typeInfo.IsDefined<IFixtureBuilder>(true))
return true;
// Generics must have an attribute in order to provide
// them with arguments to determine the specific type.
// TODO: What about automatic fixtures? Should there
// be some kind of error shown?
if (typeInfo.IsGenericTypeDefinition)
return false;
return typeInfo.HasMethodWithAttribute(typeof(IImplyFixture));
}