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.
--
"Quae narravi, nullo modo negabo."
Lee Crabtree said:
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
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.