From 9ddd8770b2201cc7100b4938649b1ee548b428d1 Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Fri, 9 Mar 2012 07:13:07 +0000 Subject: [PATCH] Added non-generic variant of the TyperHelper.HasAttribute() method git-svn-id: file:///srv/devel/repo-conversion/nusu@274 d2e56fa2-650e-0410-a79f-9358c0239efd --- Source/TypeHelper.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/TypeHelper.cs b/Source/TypeHelper.cs index 5778ee6..9a66272 100644 --- a/Source/TypeHelper.cs +++ b/Source/TypeHelper.cs @@ -163,7 +163,17 @@ namespace Nuclex.Support { /// /// True if the type has the specified attribute, otherwise false public static bool HasAttribute(this Type type) { - object[] attributes = type.GetCustomAttributes(typeof(TAttribute), true); + return type.HasAttribute(typeof(TAttribute)); + } + + /// Determines whether the type has the specified attribute + /// + /// Type that will be checked for presence of the specified attribute + /// + /// Attribute the type will be checked for + /// True if the type has the specified attribute, otherwise false + public static bool HasAttribute(this Type type, Type attributeType) { + object[] attributes = type.GetCustomAttributes(attributeType, true); return (attributes != null) && (attributes.Length > 0); }