vendredi 10 juillet 2015

How to use reflection to find certain classes in an assembly? [duplicate]

This question already has an answer here:

If I have a .Net assembly loaded and I want to use reflection to find the classes (types) decorated with some attribute, eg

[MyClassAttribute]
public SomeClass
{
} 

how do I do it in C#? I have got as far as

Assembly assy = Assembly.Load(assyPath);
var classesInAssy = assy.GetTypes();

but thereafter I'm stumped. The type's Typeattributes collection isn't what I need.

I'm using .Net4.5 for this exercise.

TIA,





Aucun commentaire:

Enregistrer un commentaire