Created
December 30, 2016 03:50
-
-
Save jpdillingham/32fb0a43b8f53a6973ae4a5f07d4e5fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Returns a value indicating whether <see cref="Type"/> of the specified object instance contains the specified <see cref="Attribute"/>. | |
/// </summary> | |
/// <typeparam name="T">The <see cref="Attribute"/> for which to check.</typeparam> | |
/// <param name="instance">The object instance to check.</param> | |
/// <returns>A value indicating whether the specified Type contains the specified Attribute.</returns> | |
public static bool HasCustomAttribute<T>(this object instance) where T : Attribute | |
{ | |
return Attribute.GetCustomAttribute(instance.GetType(), typeof(T)) != default(Attribute); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment