> > I have a currently executing assembly with 3 types, they are all
> > decorated with a Custom Attribute. Can anyone show a sample of how to
[quoted text clipped - 6 lines]
> .Where(t=>t.IsDefined(typeof(MyAttibute), false)
> .Select(t=>Activator.CreateInstance(t));
The result type is wrong there, but hey, who's counting :)
I prefer it as a query expression though:
var result = from type in Assembly.GetExecutingAssembly().GetTypes()
where type.IsDefined(typeof(MyAttribute), false)
select Activator.CreateInstance(type);
List<object> objects = result.ToList();

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Alun Harford - 08 Dec 2007 15:22 GMT
>>> I have a currently executing assembly with 3 types, they are all
>>> decorated with a Custom Attribute. Can anyone show a sample of how to
[quoted text clipped - 7 lines]
>
> The result type is wrong there, but hey, who's counting :)
That'll teach me for answering questions at 1am :-)
Good catch!
Alun Harford