using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Reflection;
namespace Reflection
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox cbo;
private System.Windows.Forms.ListBox l3;
private System.Windows.Forms.ListBox l2;
private System.Windows.Forms.ListBox l1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.cbo = new System.Windows.Forms.ComboBox();
this.l2 = new System.Windows.Forms.ListBox();
this.l3 = new System.Windows.Forms.ListBox();
this.l1 = new System.Windows.Forms.ListBox();
this.label1 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button1.Location = new System.Drawing.Point(240, 72);
this.button1.Name = "button1";
this.button1.TabIndex = 4;
this.button1.Text = "List";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.Font = new System.Drawing.Font("Comic Sans MS", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label2.Location = new System.Drawing.Point(48, 112);
this.label2.Name = "label2";
this.label2.TabIndex = 6;
this.label2.Text = "Methods";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Font = new System.Drawing.Font("Comic Sans MS", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label3.Location = new System.Drawing.Point(216, 112);
this.label3.Name = "label3";
this.label3.TabIndex = 7;
this.label3.Text = "Interfaces";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// cbo
//
this.cbo.DropDownWidth = 121;
this.cbo.Font = new System.Drawing.Font("Times New Roman", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.cbo.Items.AddRange(new object[] {
"System.String",
"System.Int32",
"System.Console"});
this.cbo.Location = new System.Drawing.Point(72, 72);
this.cbo.Name = "cbo";
this.cbo.Size = new System.Drawing.Size(121, 21);
this.cbo.TabIndex = 3;
//
// l2
//
this.l2.Font = new System.Drawing.Font("Times New Roman", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.l2.Location = new System.Drawing.Point(184, 136);
this.l2.Name = "l2";
this.l2.Size = new System.Drawing.Size(160, 43);
this.l2.TabIndex = 1;
//
// l3
//
this.l3.Font = new System.Drawing.Font("Times New Roman", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.l3.Location = new System.Drawing.Point(352, 136);
this.l3.Name = "l3";
this.l3.Size = new System.Drawing.Size(136, 43);
this.l3.TabIndex = 0;
//
// l1
//
this.l1.Font = new System.Drawing.Font("Times New Roman", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.l1.Location = new System.Drawing.Point(8, 136);
this.l1.Name = "l1";
this.l1.Size = new System.Drawing.Size(168, 43);
this.l1.TabIndex = 2;
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(456, 40);
this.label1.TabIndex = 5;
this.label1.Text = "Select from the Combo box, the class about which you would like to see the detail" +
"s. ";
//
// label4
//
this.label4.Font = new System.Drawing.Font("Comic Sans MS", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label4.Location = new System.Drawing.Point(376, 112);
this.label4.Name = "label4";
this.label4.TabIndex = 8;
this.label4.Text = "Fields";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(7, 19);
this.ClientSize = new System.Drawing.Size(496, 197);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label4,
this.label3,
this.label2,
this.label1,
this.button1,
this.cbo,
this.l1,
this.l2,
this.l3});
this.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
l1.Items.Clear();
l2.Items.Clear();
l3.Items.Clear();
string s = cbo.Text;
switch (s)
{
case "System.String": GetStringInfo();break;
case "System.Int32" :GetIntInfo();break;
case "System.Console" :GetConsoleInfo();break;
default : break;
};
}
public void GetStringInfo()
{
Type t = typeof(System.String);
MemberInfo[] m = t.GetMethods();
foreach (MemberInfo m1 in m)
{
l1.Items.Add(m1);
}
MemberInfo[] i = t.GetInterfaces();
foreach(MemberInfo i1 in i)
{
l2.Items.Add(i1);
}
MemberInfo[] f = t.GetFields();
foreach(MemberInfo f1 in f)
{
l3.Items.Add(f1);
}
return;
}
public void GetIntInfo()
{
Type t = typeof(System.Int32);
MemberInfo[] m = t.GetMethods();
foreach (MemberInfo m1 in m)
{
l1.Items.Add(m1);
}
MemberInfo[] i = t.GetInterfaces();
foreach(MemberInfo i1 in i)
{
l2.Items.Add(i1);
}
MemberInfo[] f = t.GetFields();
foreach(MemberInfo f1 in f)
{
l3.Items.Add(f1);
}
return;
}
public void GetConsoleInfo()
{
Type t = typeof(System.Console);
MemberInfo[] m = t.GetMethods();
foreach (MemberInfo m1 in m)
{
l1.Items.Add(m1);
}
MemberInfo[] i = t.GetInterfaces();
foreach(MemberInfo i1 in i)
{
l2.Items.Add(i1);
}
MemberInfo[] f = t.GetFields();
foreach(MemberInfo f1 in f)
{
l3.Items.Add(f1);
}
return;
}
}
}