473,395 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Find inherited classes / walk inheritance tree

Hi,

I have a Class-Tree based on "Command-Pattern"

eg.
public class Calculator
{ ....
}

public abstract class command
{ ..
public abstract void Execute()
{
}
}

public class commandAlpha : command
{ ...
public commandAlpha(Calculator calulator, float alpha)
{
}
}

public class commandGamma : command
{ ...
public commandAlpha(Calculator calulator, float gamma)
{
}
}
public class commandGamma2 : command
{ ...
public commandAlpha(Calculator calulator, float gamma, deviation
float)
{
}
}
.....
Now i will add a Userinterface to test the calculator.
A Combobox should show all Commands, but i will not "hardcode" them to
the combobox. My Ideea is to find all "SubClasses of command" and add
the Type to the Combobox .
1) How can I find all Subclasses of a Class/Type ?
2) How can I find all Subclasses of a Class/Type if there are different
Namspaces/Assemblies ?
Thank you
Peter

May 21 '06 #1
3 3379
you should do the following:
1. determine which assemblies could contain SubClasses of command. all
in specified folder, all on computer... etc.. once you have this you
iterate through them
2. for each assembly iterate through all types by using Reflection
http://msdn2.microsoft.com/en-US/lib....gettypes.aspx

3. for each type use Type.BaseType Property (probably recursive) to
check if one of them is abstract Command class.

I hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com

May 21 '06 #2
Thank you
this helps.
- is there a way to "find all Assemblies involved in
"The_Current_Application"

Peter

May 21 '06 #3
take a look at Assembly.GetReferencedAssemblies Method

http://msdn2.microsoft.com/en-us/lib...ssemblies.aspx

thus way you can start from single assembly and get all dependency ones

hope ths helps
Galin Iliev[MCSD.NET]
www.galcho.com

May 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Greg Yasko | last post by:
Hi. Does anyone know if there's an equivalent of Perl's file::find module in Python? It traverses a directory. I've googled extensively and checked this newsgroup and can't find anything like it...
0
by: Frnak McKenney | last post by:
I'm running into problems with VisualStudio.NET2003 and Windows Forms inheritance. It _feels_ like a bug, but it could just as well be a misunderstanding on my part regarding how the VS Designer...
4
by: Bryan Green | last post by:
So I'm working on a project for a C# class I'm taking, where I need to keep some running totals via static variables. I need three classes for three different types of objects. The base class and...
4
by: Sebastian Böck | last post by:
Hello all, i have a view defined as a simple select of a table. This table is inherited by a couple of others. All entries belong to the child-tables. I also have an unconditional update rule...
6
by: Peter Oliphant | last post by:
I just discovered that the ImageList class can't be inherited. Why? What could go wrong? I can invision a case where someone would like to add, say, an ID field to an ImageList, possible so that...
12
by: Ben | last post by:
I have a group of settings that I'd like to have inherited by multiple sites. I'm trying this, but it's not working. wwwroot\group\web.config wwwroot\group\site1\web.config...
14
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming...
21
by: George Exarchakos | last post by:
Hi everyone, I'd like your help... Can we have a std::list<BASEwhere BASE be the base class of a class hierarchy? I want to add to this list objects that are inherited from BASE class but not...
3
by: djsuson | last post by:
I'm trying to set up an inheritance tree that also uses templates. This is an attempt to simplify some previous code that was filled with redundancies. I'm working with g++ 3.4.6. The code is split...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.