本文整理汇总了C#中System.Reflection.TypeInfo.IsDefined方法的典型用法代码示例。如果您正苦于以下问题:C# TypeInfo.IsDefined方法的具体用法?C# TypeInfo.IsDefined怎么用?C# TypeInfo.IsDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.TypeInfo
的用法示例。
在下文中一共展示了TypeInfo.IsDefined方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsDispatcherHandler
private bool IsDispatcherHandler(TypeInfo typeInfo)
{
return typeInfo.IsDefined(typeof(DispatcherHandlerAttribute))
&& typeInfo.IsClass
&& typeInfo.IsPublic
&& !typeInfo.IsAbstract
&& !typeInfo.IsGenericTypeDefinition
&& !typeInfo.ContainsGenericParameters;
}
示例2: IsController
/// <summary>
/// Returns <c>true</c> if the <paramref name="typeInfo"/> is a controller. Otherwise <c>false</c>.
/// </summary>
/// <param name="typeInfo">The <see cref="TypeInfo"/>.</param>
/// <param name="candidateAssemblies">The set of candidate assemblies.</param>
/// <returns><c>true</c> if the <paramref name="typeInfo"/> is a controller. Otherwise <c>false</c>.</returns>
protected internal virtual bool IsController(
TypeInfo typeInfo,
ISet<Assembly> candidateAssemblies)
{
if (typeInfo == null)
{
throw new ArgumentNullException(nameof(typeInfo));
}
if (candidateAssemblies == null)
{
throw new ArgumentNullException(nameof(candidateAssemblies));
}
if (!typeInfo.IsClass)
{
return false;
}
if (typeInfo.IsAbstract)
{
return false;
}
// We only consider public top-level classes as controllers. IsPublic returns false for nested
// classes, regardless of visibility modifiers
if (!typeInfo.IsPublic)
{
return false;
}
if (typeInfo.ContainsGenericParameters)
{
return false;
}
if (!typeInfo.Name.EndsWith(ControllerTypeName, StringComparison.OrdinalIgnoreCase) &&
!DerivesFromController(typeInfo, candidateAssemblies))
{
return false;
}
if (typeInfo.IsDefined(typeof(NonControllerAttribute)))
{
return false;
}
return true;
}
示例3: IsComponent
public static bool IsComponent(TypeInfo typeInfo)
{
if (typeInfo == null)
{
throw new ArgumentNullException(nameof(typeInfo));
}
if (!typeInfo.IsClass ||
!typeInfo.IsPublic ||
typeInfo.IsAbstract ||
typeInfo.ContainsGenericParameters)
{
return false;
}
return
typeInfo.Name.EndsWith(ViewComponentSuffix, StringComparison.OrdinalIgnoreCase) ||
typeInfo.IsDefined(typeof(ViewComponentAttribute));
}
示例4: AllPublicTypesShouldBeAnnotatedWithPublicAPIAttribute
public void AllPublicTypesShouldBeAnnotatedWithPublicAPIAttribute(TypeInfo type)
{
Assert.True(type.IsDefined(typeof(PublicAPIAttribute), true));
}
示例5: Create
internal static HarshEntityMetadata Create(HarshEntityMetadataRepository repository, TypeInfo typeInfo)
{
if (repository == null)
{
throw Logger.Fatal.ArgumentNull(nameof(repository));
}
if (typeInfo == null)
{
throw Logger.Fatal.ArgumentNull(nameof(typeInfo));
}
if (typeInfo.IsDefined(typeof(ContentTypeAttribute), inherit: false))
{
return new HarshEntityMetadataContentType(repository, typeInfo);
}
throw new NotImplementedException("TODO: more entity types to come :)");
}