﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <description><![CDATA[Comments for Write your own Reflector - by Alain "Lino" Tadros]]></description>
    <title><![CDATA[Comments for Write your own Reflector - by Alain "Lino" Tadros]]></title>
    <link>http://dn.codegear.com/article/29423</link>
    <!-- source: http://dn.codegear.com/article/29423/feed-->
    <dc:date>2008-11-21T14:54:15-08:00</dc:date>
    <item>
      <description><![CDATA[I follow these articles from a C# point of view. I took the liberty in translating the reflection example into C#. (Obs. I load the \Microsoft.NET\Framework\v1.0.3705\mscorlib.dll in this example).Compile with "csc *.cs" and run ReflectionDemo.exeReflectionDemo.cs:using System.Windows.Forms;using Reflection.Form;namespace Reflection{public class ReflectionDemo{public static void Main(){ReflectionForm theReflectionForm = new ReflectionForm();Application.Run(theReflectionForm);}}}ReflectionForm.cs:using System;using System.Windows.Forms;using System.ComponentModel;using System.Drawing;using System.Reflection;namespace Reflection.Form{public class ReflectionForm : System.Windows.Forms.Form{private Container PreContainer;private StatusBar stBar;private Button btnLoad;private TreeView TV;public void btnLoad_Click(Object Sender, EventArgs E){String SysRoot;Assembly Assm;System.Type[] t;int i, iprop;int PropertyCount = 0;int MethodCount = 0;int FieldCount = 0;int EventCount = 0;;TreeNode TN, TNProp, TNMethod, TNEvent, TNField;SysRoot = Environment.GetEnvironmentVariable("systemroot");try{Assm = Assembly.LoadFrom(SysRoot + "\\Microsoft.NET\\Framework\\v1.0.3705\\mscorlib.dll");t = Assm.GetTypes();for (i = 0; i &lt; Assm.GetTypes().Length; i++){TN = TV.Nodes.Add(t[i].Name);PropertyCount = PropertyCount + t[i].GetProperties().GetUpperBound(0) + 1;TNProp = TN.Nodes.Add("Properties");for (iprop = 0; iprop &lt; t[i].GetProperties().Length; iprop++)TNProp.Nodes.Add(t[i].GetProperties().GetValue(iprop).ToString());MethodCount = MethodCount + t[i].GetMethods().GetUpperBound(0) + 1;TNMethod = TN.Nodes.Add("Methods");for (iprop = 0; iprop &lt; t[i].GetMethods().Length; iprop++)TNMethod.Nodes.Add(t[i].GetMethods().GetValue(iprop).ToString());FieldCount = FieldCount + t[i].GetFields().GetUpperBound(0) + 1;TNField = TN.Nodes.Add("Fields");for (iprop= 0; iprop &lt; t[i].GetFields().Length; iprop++)TNField.Nodes.Add(t[i].GetFields().GetValue(iprop).ToString());EventCount = EventCount + t[i].GetEvents().GetUpperBound(0) + 1;TNEvent = TN.Nodes.Add("Events");for (iprop = 0; iprop &lt; t[i].GetEvents().Length; iprop++)TNEvent.Nodes.Add(t[i].GetEvents().GetValue(iprop).ToString());}}catch(Exception ex){MessageBox.Show("Kaboom!! Problems loading the assembly: " + ex.Message); //implement your own exception handling here.}this.Text = "Properties=" + System.Convert.ToString(PropertyCount) + "  Methods=" + System.Convert.ToString(MethodCount) + " Fields=" + System.Convert.ToString(FieldCount) + " Events=" + System.Convert.ToString(EventCount);stBar.Text = "Done";}public ReflectionForm() : base(){Initialize();}public void Initialize(){Control[] MyControls = new Control[3];MyControls.Initialize();this.PreContainer = new System.ComponentModel.Container();this.TV = new TreeView();this.stBar = new StatusBar();this.btnLoad = new Button();this.TV.Size = new Size(584, 336);this.TV.TabIndex = 0;this.TV.Anchor = ((AnchorStyles.Top) |(AnchorStyles.Bottom) |(AnchorStyles.Left) |(AnchorStyles.Right));this.TV.Location = new Point(8, 8);this.AutoScaleBaseSize = new Size(5, 13);this.Text = "Reflection Demo";this.AcceptButton = btnLoad as IButtonControl;this.ClientSize = new Size(600, 400);this.stBar.BackColor = SystemColors.Control;this.stBar.Location = new Point(0, 397);this.stBar.Size = new Size(600, 16);this.stBar.TabIndex = 2;this.stBar.Text = "Click to Reflect";this.btnLoad.Anchor = ((AnchorStyles.Right) | (AnchorStyles.Bottom));this.btnLoad.Click += new EventHandler(btnLoad_Click);this.btnLoad.FlatStyle = FlatStyle.Flat;this.btnLoad.Location = new Point(480, 352);this.btnLoad.Size = new Size(112, 32);this.btnLoad.TabIndex = 1;this.btnLoad.Text = "&amp;Reflect";MyControls[0] = this.stBar;MyControls[1] = this.btnLoad;MyControls[2] = TV;this.Controls.AddRange(MyControls);}}}]]></description>
      <title><![CDATA[Write your own Reflector - by Alain ]]></title>
      <managingEditor>
	 (hallgrim flatland)
</managingEditor>
      <guid isPermaLink="true">http://threads.codegear.com/threads/threads.exe/view?commentid=34357</guid>
      <dc:date>2003-03-27T05:53:13-07:00</dc:date>
      <pubDate>2003-03-27T05:53:13-07:00</pubDate>
      <source url="http://dn.codegear.com/article/29423/feed">Comments for Write your own Reflector - by Alain "Lino" Tadros</source>
    </item>
    <item>
      <description><![CDATA[if you don't have more than the official ²Net framework downloaded, make caution to modify the :\Microsoft.NET\Framework\v1.1.4322\mscorlib.dllin\Microsoft.NET\Framework\v1.0.3705\mscorlib.dllWorks very fine !!Regards from DoubleTree in S.J.stjo.com - stjo.net²Net Borland France]]></description>
      <title><![CDATA[Write your own Reflector - by Alain ]]></title>
      <managingEditor>
	 (Stephane JOUANNEAU)
</managingEditor>
      <guid isPermaLink="true">http://threads.codegear.com/threads/threads.exe/view?commentid=33932</guid>
      <dc:date>2003-01-18T08:05:50-08:00</dc:date>
      <pubDate>2003-01-18T08:05:50-08:00</pubDate>
      <source url="http://dn.codegear.com/article/29423/feed">Comments for Write your own Reflector - by Alain "Lino" Tadros</source>
    </item>
    <generator>Atom 1.0 XSLT Transform v1 (http://atom.geekhood.net)</generator>
  </channel>
</rss>