Retrieve Classes with Attribute

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Besides looping through all the types in an assembly, is there any way to
retreive all of the classes that have a custome attribute applied?

For example, I have a PersistentAttribute, I won't to retrieve all of the
types that have the attribute applied. The type can only be used at the
class level. I would like ot avoid looping through all the types of the
assembly if I don't have to.
 
Jesse said:
Besides looping through all the types in an assembly, is there any way to
retreive all of the classes that have a custome attribute applied?

Not that I know of.
For example, I have a PersistentAttribute, I won't to retrieve all of the
types that have the attribute applied. The type can only be used at the
class level. I would like ot avoid looping through all the types of the
assembly if I don't have to.

Why, out of interest? Have you got concrete data showing that this
would be a problem in terms of performance?
 
Besides looping through all the types in an assembly, is there any way to
retreive all of the classes that have a custome attribute applied?

For example, I have a PersistentAttribute, I won't to retrieve all of the
types that have the attribute applied. The type can only be used at the
class level. I would like ot avoid looping through all the types of the
assembly if I don't have to.


Well you could use an assembly or module level attribute instead, that
simply lists the names of all classes you're interested in. That way
you can avoid loading metadata for all types.



Mattias
 
Back
Top