Added non-generic variant of the TyperHelper.HasAttribute() method
git-svn-id: file:///srv/devel/repo-conversion/nusu@274 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
07d1b026f1
commit
9ddd8770b2
|
@ -163,7 +163,17 @@ namespace Nuclex.Support {
|
|||
/// </param>
|
||||
/// <returns>True if the type has the specified attribute, otherwise false</returns>
|
||||
public static bool HasAttribute<TAttribute>(this Type type) {
|
||||
object[] attributes = type.GetCustomAttributes(typeof(TAttribute), true);
|
||||
return type.HasAttribute(typeof(TAttribute));
|
||||
}
|
||||
|
||||
/// <summary>Determines whether the type has the specified attribute</summary>
|
||||
/// <param name="type">
|
||||
/// Type that will be checked for presence of the specified attribute
|
||||
/// </param>
|
||||
/// <name="attributeType">Attribute the type will be checked for</typeparam>
|
||||
/// <returns>True if the type has the specified attribute, otherwise false</returns>
|
||||
public static bool HasAttribute(this Type type, Type attributeType) {
|
||||
object[] attributes = type.GetCustomAttributes(attributeType, true);
|
||||
return (attributes != null) && (attributes.Length > 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user