I\'ve got a .NET library in which I need to find all the classes which have a custom attribute I\'ve defined on them, and I want to be able to find them on-the-fly when an a
IEnumerable GetTypesWith(bool inherit)
where TAttribute: System.Attribute
{ return from a in AppDomain.CurrentDomain.GetAssemblies()
from t in a.GetTypes()
where t.IsDefined(typeof(TAttribute),inherit)
select t;
}