Solved

Simple reflection question

Posted on 2008-10-07
3
188 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
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 55

Expert Comment

by:Jaime Olivares
ID: 22660153
0
 
LVL 12

Accepted Solution

by:
ShazbotOK earned 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error in script 11 55
Web Form VB.Net  import CSV 4 36
Where did System.Data.Objects go? 2 23
.NET 2008 VB and C# 6 27
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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