I need to retrieve all enums that were loaded from a given set of Assemblies.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Assuming you have the list of
Assembly
objects you want to check:Here is a more functional solution:
That should do, for all assemblies loaded by the current Appdomain, to get just from defined assemblies, just adjust ;-)
You should be able to use
Assembly.GetTypes()
to get all the types for the assembly. For each type, you can useType.IsEnum
property to see if it's an enum.You can also use LINQ to return a list of all enum types from a list of assemblies.
enums
will be of type IEnumerable.