Reflector Utilities : Reflection « Development « VB.Net






Reflector Utilities

   

Imports System.Windows.Forms
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Reflector
    Inherits System.Windows.Forms.Form
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.lblAssembly = New System.Windows.Forms.Label
        Me.treeTypes = New System.Windows.Forms.TreeView
        Me.cmdReflect = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'lblAssembly
        '
        Me.lblAssembly.Location = New System.Drawing.Point(10, 9)
        Me.lblAssembly.Name = "lblAssembly"
        Me.lblAssembly.Size = New System.Drawing.Size(272, 12)
        Me.lblAssembly.TabIndex = 5
        '
        'treeTypes
        '
        Me.treeTypes.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.treeTypes.Location = New System.Drawing.Point(10, 29)
        Me.treeTypes.Name = "treeTypes"
        Me.treeTypes.Size = New System.Drawing.Size(362, 276)
        Me.treeTypes.TabIndex = 4
        '
        'cmdReflect
        '
        Me.cmdReflect.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cmdReflect.Location = New System.Drawing.Point(300, 313)
        Me.cmdReflect.Name = "cmdReflect"
        Me.cmdReflect.Size = New System.Drawing.Size(72, 28)
        Me.cmdReflect.TabIndex = 3
        Me.cmdReflect.Text = "Reflect"
        '
        'Reflector
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(382, 350)
        Me.Controls.Add(Me.lblAssembly)
        Me.Controls.Add(Me.treeTypes)
        Me.Controls.Add(Me.cmdReflect)
        Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Name = "Reflector"
        Me.Text = "Reflector"
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents lblAssembly As System.Windows.Forms.Label
    Friend WithEvents treeTypes As System.Windows.Forms.TreeView
    Friend WithEvents cmdReflect As System.Windows.Forms.Button

    Private Sub cmdReflect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReflect.Click
        treeTypes.Nodes.Clear()

        Dim MyAssembly As System.Reflection.Assembly
        MyAssembly = System.Reflection.Assembly.GetExecutingAssembly()
        lblAssembly.Text = MyAssembly.FullName

        Dim MyTypes(), MyType As Type
        Dim MyEvents(), MyEvent As System.Reflection.EventInfo
        Dim MyMethods(), MyMethod As System.Reflection.MethodInfo
        Dim MyProperties(), MyProperty As System.Reflection.PropertyInfo

        MyTypes = MyAssembly.GetTypes()
        For Each MyType In MyTypes
            Dim nodeParent As TreeNode = treeTypes.Nodes.Add(MyType.FullName)

            Dim node As TreeNode = nodeParent.Nodes.Add("Events")
            MyEvents = MyType.GetEvents
            For Each MyEvent In MyEvents
                node.Nodes.Add(MyEvent.Name & " - event handler signature: " & _
                 MyEvent.EventHandlerType.Name)
            Next

            node = nodeParent.Nodes.Add("Methods")
            MyMethods = MyType.GetMethods()
            For Each MyMethod In MyMethods
                node.Nodes.Add(MyMethod.Name)
            Next

            node = nodeParent.Nodes.Add("Properties")
            MyProperties = MyType.GetProperties
            For Each MyProperty In MyProperties
                node.Nodes.Add(MyProperty.Name & "- data type: " & _
                MyProperty.PropertyType.ToString())
            Next
        Next

    End Sub
End Class

   
    
    
  








Related examples in the same category

1.Reflection Information for Integer ClassReflection Information for Integer Class
2.Fill Reflection Data into ListViewFill Reflection Data into ListView
3.Use Reflection to create Class instance and call methodUse Reflection to create Class instance and call method
4.Define Attributes and Use Reflection to get its valueDefine Attributes and Use Reflection to get its value
5.Get Method information and invoke Method using Reflection APIGet Method information and invoke Method using Reflection API
6.Get Method InformationGet Method Information
7.Get Class Member and Property Information from base and inherited ClassGet Class Member and Property Information from base and inherited Class
8.Reflection: display the member of Form ClassReflection: display the member of Form Class
9.The AssemblyCopyrightAttribute sets the Copyright field on the Version tab.
10.The AssemblyDescriptionAttribute sets the Comment item.
11.The AssemblyCompanyAttribute sets the Company item
12.The AssemblyProductAttribute sets the Product Name item
13.Define the assembly's only module. For a single-file assembly, the module name is the assembly name.
14.The AssemblyTitleAttribute sets the Description field on the General tab and the Version tab of the Windows file properties dialog.