开发者

C# class scanning

开发者 https://www.devze.com 2022-12-23 00:51 出处:网络
In Java there are methods to go about scanning the classpath/all classes/within a package and enumerating the classes therein.e.g. spring component scanning uses somet开发者_StackOverflowhing like thi

In Java there are methods to go about scanning the classpath/all classes/within a package and enumerating the classes therein. e.g. spring component scanning uses somet开发者_StackOverflowhing like this to scan all classes and find those with an interesting annotation.

If there any similar technique for C# and if so what are the APIs to use?


The Reflection API is the way you would do this via C#.

You can use the Assembly class to look at assemblies (ie: packages). Within the assembly, you can use Assembly.GetTypes to retrieve a list of all of the classes.

The first link above demonstrates quite a few options of how this can be used.

0

精彩评论

暂无评论...
验证码 换一张
取 消