GetCustomAttributes method can cast attributes

This commit is contained in:
Chris Cameron
2017-10-05 17:16:49 -04:00
parent 3b0bab02de
commit 70c5f817c5

View File

@@ -245,14 +245,14 @@ namespace ICD.Common.Utils
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="assembly"></param> /// <param name="assembly"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<object> GetCustomAttributes<T>(Assembly assembly) public static IEnumerable<T> GetCustomAttributes<T>(Assembly assembly)
where T : Attribute where T : Attribute
{ {
if (assembly == null) if (assembly == null)
throw new ArgumentNullException("assembly"); throw new ArgumentNullException("assembly");
#if SIMPLSHARP #if SIMPLSHARP
return assembly.GetCustomAttributes(typeof(T), false); return assembly.GetCustomAttributes(typeof(T), false).Cast<T>();
#else #else
return assembly.GetCustomAttributes<T>(); return assembly.GetCustomAttributes<T>();
#endif #endif