mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 12:45:01 +00:00
GetCustomAttributes method can cast attributes
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user