Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Simple reflection question

Posted on 2008-10-07
3
Medium Priority
?
197 Views
Last Modified: 2010-05-18
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.

0
Comment
Question by:craigdev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Expert Comment

by:crazyman
ID: 22659992
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
 
LVL 12

Accepted Solution

by:
ShazbotOK earned 2000 total points
ID: 22660222

        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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

647 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question