.NET by Patrik

Get Methods with Custom Attribute

Use C# reflection to get all methods with a custom attribute.

Method[] methodInfos = Assembly.GetCallingAssembly()
   .GetTypes()
   .SelectMany(t => t.GetMethods())
   .Where(m => Attribute.IsDefined(m, typeof(CustomAttribute)))
   .ToArray();

Additional Resources:

Reflection

Comments