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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -