mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 04:35:00 +00:00
Created S# .sln and moved project to src folder
This commit is contained in:
32
ICD.Common/Utils/Extensions/ReflectionExtensions.cs
Normal file
32
ICD.Common/Utils/Extensions/ReflectionExtensions.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
#if SIMPLSHARP
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Crestron.SimplSharp.Reflection;
|
||||
|
||||
namespace ICD.Common.Utils.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for use with reflection objects.
|
||||
/// </summary>
|
||||
public static class ReflectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the custom attributes attached to the member.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="extends"></param>
|
||||
/// <param name="inherits"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> GetCustomAttributes<T>(this MemberInfo extends, bool inherits)
|
||||
where T : Attribute
|
||||
{
|
||||
if (extends == null)
|
||||
throw new ArgumentNullException("extends");
|
||||
|
||||
return extends.GetCustomAttributes(typeof(T), inherits).Cast<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user