Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / August 2006

Tip: Looking for answers? Try searching our database.

diagram a class structure with reflection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee Crabtree - 30 Aug 2006 21:20 GMT
Are there any tools that will take an existing assembly and generate a
class hierarchy from it?  It seems like the kind of thing that would be
possible with reflection, but I don't know enough about that namespace
to tackle this.

Lee Crabtree
UsualDosage - 30 Aug 2006 21:52 GMT
You can use reflection to iterrate through methods, properties, etc. Using
this information, you could easily add these items as entries in a ListView
or a TreeView (then serialize it to XML, if so desired).

Here's a quick snippet that gets methods and properties from a TextBox
object, and adds them to a ListView (Be sure to include the System.Reflection
namespace):

private void button1_Click(object sender, System.EventArgs e)
{
    Type t = typeof(TextBox);
    //Get method info for an object
    MethodInfo[] mI = t.GetMethods();
    for (int x=0; x<mI.Length; x++)
    {   
        ListViewItem lvi = new ListViewItem();
        lvi.Text = mI[x].Name;
        this.listBox1.Items.Add(lvi);
    }
    //Get properties for an object
    PropertyInfo[] pI = t.GetProperties();
    for (int x=0; x<pI.Length; x++)
    {   
        ListViewItem lvi = new ListViewItem();
        lvi.Text = pI[x].Name;
        this.listBox1.Items.Add(lvi);
    }
}

Hope it helps.

Signature

"Quae narravi, nullo modo negabo."

> Are there any tools that will take an existing assembly and generate a
> class hierarchy from it?  It seems like the kind of thing that would be
> possible with reflection, but I don't know enough about that namespace
> to tackle this.
>
> Lee Crabtree
Lee Crabtree - 30 Aug 2006 22:24 GMT
What about subclass/superclass info?  Is that just stored as a property
of a Type?  That's the major thing I want to see to begin with.

Lee Crabtree

> You can use reflection to iterrate through methods, properties, etc. Using
> this information, you could easily add these items as entries in a ListView
[quoted text clipped - 26 lines]
>
> Hope it helps.
UsualDosage - 30 Aug 2006 23:00 GMT
Using the Type object, you should be able to locate anything and everything
you need regarding the object in question. It has methods for accessing
Assembly info, Interfaces, Fields, Properties, Methods, Attributes, Events,
Default Constructors...You name it, it contains it.

Just start by declaring a Type object of the type of object you are looking
to diagram: Type t = typeof(myObject); Then, just do a "t.", and the
Intellisense will give you an idea of what it can get for you.

If you're looking to diagram a class library, alternatively, I believe you
can just use Visio to diagram the class, which works well for visual
presentations.

Signature

"Quae narravi, nullo modo negabo."

> What about subclass/superclass info?  Is that just stored as a property
> of a Type?  That's the major thing I want to see to begin with.
[quoted text clipped - 31 lines]
> >
> > Hope it helps.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.