Skip to content

Instantly share code, notes, and snippets.

@CapitanLiteral
Created November 2, 2019 23:17
Show Gist options
  • Save CapitanLiteral/1a6c31f52d428583db2948a383a9d794 to your computer and use it in GitHub Desktop.
Save CapitanLiteral/1a6c31f52d428583db2948a383a9d794 to your computer and use it in GitHub Desktop.
public static IEnumerable<Type> GetTypesWith<TAttribute>(bool inherit)
where TAttribute : Attribute
{
return AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a => a.GetTypes())
.Where(t => t.IsDefined(typeof(TAttribute), inherit));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment