Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2005, 02:03 PM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can I enumerate through the classes in a Namespace

Hi:

I'm finding it extremely difficult to get information.
Even Wrox Professional C# isn't helping here.

Is it possible to get a collection of all the classes in a given namespace and then enumerate through them?

Now, I know I could create a collection and then programmatically enter an object for each class . . .

I've got a namespace full of classes.
This function gets an object of a class out of that namespace, based on a variable.

I don't want to have to hard code each class into this function.
The classes will come and go from time to time.

I'd like to 'find' the class based on the value in the variable.
Is there ANY way to do that?


__________________
http://www.softlinksys.com
Professional Software Developer since 1994.
 
Old July 30th, 2005, 08:01 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to learn the classes and tools in the System.Reflection namespace. There are methods in there to allow you to load assemblies, explore them, get items of types (properties, fields, methods, etc). I imagine there is a way to get all the classes (Types) of a namespace as well though I don't know off hand what the method calls are for this.

-Peter
 
Old July 31st, 2005, 07:50 PM
Authorized User
 
Join Date: Feb 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is no way to do this.
You must iterate through all classes and note which ones have the Namespace value you want.

i.e., Namespaces are a property of types - they are not a container for types (although it may appear that way from the structure of source code).


 
Old August 1st, 2005, 11:58 AM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looks like reflection won't help with this, but I really just want to create the class from the name so plan A might work.

Thanks for the help:)






Similar Threads
Thread Thread Starter Forum Replies Last Post
enumerate db2 server... sal21 VB Databases Basics 0 February 6th, 2007 07:39 AM
Problem with the namespace & classes ayamas .NET Framework 2.0 2 November 25th, 2006 02:13 PM
Problems with namespace & classes ayamas Visual Studio 2005 0 October 12th, 2006 08:56 AM
process could not enumerate changes at the subscri rstelma SQL Server 2000 2 June 21st, 2006 09:50 PM
Enumerate SQL data sources RFickling C# 0 May 22nd, 2005 10:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.