Get Methods With Attribute
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace RestCake.Util
{
internal static class ReflectionHelper
{
public static IEnumerable<MethodInfo> GetMethodsWithAttribute(Type classType, Type attributeType)
{
return classType.GetMethods().Where(methodInfo => methodInfo.GetCustomAttributes(attributeType, true).Length > 0);
}
public static IEnumerable<MemberInfo> GetMembersWithAttribute(Type classType, Type attributeType)
{
return classType.GetMembers().Where(memberInfo => memberInfo.GetCustomAttributes(attributeType, true).Length > 0);
}
}
}
Related examples in the same category