Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
4Activity
0 of .
Results for:
No results containing your search query
P. 1
system

system

Ratings:

5.0

(2)
|Views: 300|Likes:
Published by SRINIVASA RAO GANTA
MWT lab programs
MWT lab programs

More info:

Published by: SRINIVASA RAO GANTA on Aug 01, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

02/01/2013

pdf

text

original

Aim:-Demonstrate how to gather information on various types included in any
assembly by using the System.Reflection namespace and some main.NET base classes.
Source code:-
Customer. Class
usingSystem;
namespaceCustomer
{
public classClient
{
publicClient()
{}public stringGetClient(String ClientID)
{
return "ID is blank";
}
}
}worker.class
usingSystem;
namespaceEmployee
{
public classWorker
{
publicWorker()
{}public stringGetWorker(String WorkerID)
{
return "ID is blank";
}
}
}individual.class
usingSystem;
namespacePerson
{
public classIndividual
{
publicIndividual()
{}public stringGetIndividual(String IndividualID)
{
return "ID is blank";
}
}
}
reflectionform.cs

usingSystem;
usingSystem.Reflection;
usingSystem.Drawing;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Windows.Forms;
usingSystem.Data;

namespaceReflection
{
public classReflectionForm : System.Windows.Forms.Form
{

privateSystem.Windows.Forms.Button GetAssemblyInfo;
privateSystem.Windows.Forms.ComboBox listAssemblies;
privateSystem.Windows.Forms.Label label1;
privateSystem.Windows.Forms.ListBox listTypes;
private System.ComponentModel.Container components = null;
privateType[] PersonTypes;
privateType[] EmployeeTypes;
privateType[] CustomerTypes;

publicReflectionForm()
{
InitializeComponent();
}protected override voidDispose( bool disposing )
{
if( disposing )
{if (components !=null)
{components.Dispose();
}base.Dispose( disposing );
}#region Windows Form Designer generated code
private voidInitializeComponent()
{this.GetAssemblyInfo = newSystem.Windows.Forms.Button();

this.listAssemblies = newSystem.Windows.Forms.ComboBox();
this.label1 = newSystem.Windows.Forms.Label();
this.listTypes = newSystem.Windows.Forms.ListBox();
this.SuspendLayout();

this.GetAssemblyInfo.Location = new System.Drawing.Point(280, 40);
this.GetAssemblyInfo.Name ="GetAssemblyInfo";
this.GetAssemblyInfo.Size = new System.Drawing.Size(75, 23);
this.GetAssemblyInfo.TabIndex = 0;
this.GetAssemblyInfo.Text = "Get Info";

this.GetAssemblyInfo.Click += new
System.EventHandler(this.btnGetInfo_Click);
DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.listAssemblies.Items.AddRange(new object[] {
"Person", "Employee", "Customer"});

this.listAssemblies.Location = new System.Drawing.Point(144, 40);
this.listAssemblies.Name ="listAssemblies";
this.listAssemblies.Size = new System.Drawing.Size(121, 21);
this.listAssemblies.TabIndex = 1;
this.listAssemblies.SelectedIndexChanged += new

System.EventHandler(this.cboAssemblies_SelectedIndexChanged);

this.label1.Location = new System.Drawing.Point(16, 40);
this.label1.Name ="label1";
this.label1.Size = new System.Drawing.Size(112, 16);
this.label1.TabIndex = 2;
this.label1.Text = "Select An Assembly: ";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.listTypes.Location = new System.Drawing.Point(8, 88);
this.listTypes.Name ="listTypes";
this.listTypes.Size = new System.Drawing.Size(376, 459);
this.listTypes.TabIndex = 3;
this.listTypes.SelectedIndexChanged += new

System.EventHandler(this.listTypes_SelectedIndexChanged);

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(479, 559);
this.Controls.Add(this.listTypes);
this.Controls.Add(this.label1);
this.Controls.Add(this.listAssemblies);
this.Controls.Add(this.GetAssemblyInfo);
this.Name ="ReflectionForm";
this.Text = "Reflection Sample";
this.Load += newSystem.EventHandler(this.ReflectionForm_Load);
this.ResumeLayout(false);

}#endregion
static voidMain()
{Application.Run(newReflectionForm());
}
private voidbtnGetInfo_Click(object sender, System.EventArgs e)
{
string SelectedAssembly = this.listAssemblies.SelectedItem.ToString();
if(SelectedAssembly =="Person")
{listTypes.Items.Clear();
LoadTypeInfo(PersonTypes);

}else if (SelectedAssembly =="Employee")
{listTypes.Items.Clear();
LoadTypeInfo(EmployeeTypes);

}else if (SelectedAssembly =="Customer")

{
listTypes.Items.Clear();
LoadTypeInfo(CustomerTypes);

}else
{
listTypes.Items.Clear();
}
}

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->