c# - Finding all classes with a particular attribute -


i've got .net library in need find classes have custom attribute i've defined on them, , want able find them on-the-fly when application using library (ie - don't want config file somewhere state assembly in and/ or class names).

i looking @ appdomain.currentdomain i'm not overly familiar , not sure how elivated privlages need (i want able run library in web app minimal trust if possible, lower trust happier i'd be). want keep performance in mind (it's .net 3.5 library linq valid!).

so appdomain.currentdomain best/ option , looping through assemblies, , types in assemblies? or there way

ienumerable<type> gettypeswith<tattribute>(bool inherit)                                tattribute: system.attribute  { return in appdomain.currentdomain.getassemblies()           t in a.gettypes()           t.isdefined(typeof(tattribute),inherit)           select t;  } 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -