Re: Custom Attribute and Instance Sample?
- From: Alun Harford <devnull@xxxxxxxxxxxxxxxxx>
- Date: Fri, 07 Dec 2007 00:42:11 +0000
coconet wrote:
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
find all of my Types in the current Assembly that have the attribute,
and then put a New instance of each type in a List?
C# 3:
Type[] result = Assembly.GetExecutingAssembly().GetTypes()
.Where(t=>t.IsDefined(typeof(MyAttibute), false)
.Select(t=>Activator.CreateInstance(t));
.
- Follow-Ups:
- Re: Custom Attribute and Instance Sample?
- From: Jon Skeet [C# MVP]
- Re: Custom Attribute and Instance Sample?
- References:
- Custom Attribute and Instance Sample?
- From: coconet
- Custom Attribute and Instance Sample?
- Prev by Date: Re: WWF Tracking
- Next by Date: Re: Custom Attribute and Instance Sample?
- Previous by thread: Re: Custom Attribute and Instance Sample?
- Next by thread: Re: Custom Attribute and Instance Sample?
- Index(es):