Simple reflection question

How do I loop through every class in a namespace?


eg. the namespace MySolution.DataAccess.Components contains objects for accessing data from sql tables - I want to loop through all the classes in this namespace.

LVL 1
craigdevAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ShazbotOKConnect With a Mentor Commented:

        public class ListedModules : System.Collections.Generic.List<System.Reflection.Module> { }
        public class ListedMethods : System.Collections.Generic.List<System.Reflection.MethodInfo> { }
        public ListedModules GetModules(System.Reflection.Assembly asm)
        {
            ListedModules lst = new ListedModules();
            lst.AddRange(asm.GetModules());
 
            return lst;
        }
        public ListedMethods GetMethods(System.Reflection.Module mod)
        {
            ListedMethods lst = new ListedMethods();
            lst.AddRange(mod.GetMethods());
 
            return lst;
        }

Open in new window

0
 
crazymanCommented:
When you say all classes in a namespace, are these classes in the same assembly ?
Since you can have merged namespaces in seperate assemblies....
0
 
Jaime OlivaresSoftware ArchitectCommented:
0
All Courses

From novice to tech pro — start learning today.