Created
December 26, 2016 23:49
-
-
Save jpdillingham/14a28c27fdacd6cffdc8255e90260379 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 the specified assembly attribute of the specified assembly. | |
/// </summary> | |
/// <typeparam name="T">The assembly attribute to return.</typeparam> | |
/// <param name="assembly">The assembly from which to retrieve the attribute.</param> | |
/// <returns>The retrieved attribute.</returns> | |
public static T GetAssemblyAttribute<T>(this System.Reflection.Assembly assembly) where T : Attribute | |
{ | |
object[] attributes = assembly.GetCustomAttributes(typeof(T), false); | |
if (attributes == null || attributes.Length == 0) | |
{ | |
return null; | |
} | |
return attributes.OfType<T>().SingleOrDefault(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment