Mega Code Archive

 
Categories / C# / Reflection
 

Get Types 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<Type> GetTypesWithAttribute(Assembly assembly, Type attributeType)         {             return assembly.GetTypes().Where(type => type.GetCustomAttributes(attributeType, true).Length > 0);         }     } }