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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -