Click here to Skip to main content
15,894,410 members
Articles / Desktop Programming / MFC

Assembly Explorer 1.0

Rate me:
Please Sign up or sign in to vote.
4.46/5 (22 votes)
21 Jan 20032 min read 110.5K   3K   39  
Simple utility to browse assembly object hierarchy
//=============================================================================== 
// Name          : PropertyProperties.cs
// Purpose       : Property properties page.
// Description   : 
// Created       : 05.Nov.2002 by Langleyben Leon, leon@srl.co.il
// Last modified : 
//===============================================================================
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Reflection;

namespace AssemblyExplorer
{
	/// <summary>
	/// Summary description for PropertyProperties.
	/// </summary>
	public class PropertyProperties : System.Windows.Forms.UserControl, IProperties
	{
		private PropertyInfo m_Property;

		#region Control Members
		private System.Windows.Forms.Label lblCanRead;
		private System.Windows.Forms.Label lblIsSpecialName;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.ListBox lbAttr;
		private System.Windows.Forms.Label lblCustAttributes;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label lblCanWrite;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label lblGetMethod;
		private System.Windows.Forms.Label lblSetMethod;
		private System.Windows.Forms.Label lblSet;
		private System.Windows.Forms.Label lblGet;
		private System.Windows.Forms.Label lblType;
		private System.Windows.Forms.Label lblReturnTypeLabel;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public PropertyProperties()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.lblCanRead = new System.Windows.Forms.Label();
			this.lblIsSpecialName = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.lbAttr = new System.Windows.Forms.ListBox();
			this.lblCustAttributes = new System.Windows.Forms.Label();
			this.label9 = new System.Windows.Forms.Label();
			this.lblCanWrite = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.lblGetMethod = new System.Windows.Forms.Label();
			this.lblSetMethod = new System.Windows.Forms.Label();
			this.lblSet = new System.Windows.Forms.Label();
			this.lblGet = new System.Windows.Forms.Label();
			this.lblType = new System.Windows.Forms.Label();
			this.lblReturnTypeLabel = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// lblCanRead
			// 
			this.lblCanRead.Location = new System.Drawing.Point(96, 72);
			this.lblCanRead.Name = "lblCanRead";
			this.lblCanRead.Size = new System.Drawing.Size(64, 23);
			this.lblCanRead.TabIndex = 59;
			// 
			// lblIsSpecialName
			// 
			this.lblIsSpecialName.Location = new System.Drawing.Point(96, 40);
			this.lblIsSpecialName.Name = "lblIsSpecialName";
			this.lblIsSpecialName.Size = new System.Drawing.Size(64, 23);
			this.lblIsSpecialName.TabIndex = 58;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(8, 72);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(80, 23);
			this.label5.TabIndex = 57;
			this.label5.Text = "Can Read";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(8, 40);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(88, 23);
			this.label4.TabIndex = 56;
			this.label4.Text = "Is Special Name";
			// 
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(8, 320);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(104, 23);
			this.label8.TabIndex = 55;
			this.label8.Text = "Custom Attributes:";
			// 
			// lbAttr
			// 
			this.lbAttr.BackColor = System.Drawing.SystemColors.Control;
			this.lbAttr.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lbAttr.Location = new System.Drawing.Point(8, 192);
			this.lbAttr.Name = "lbAttr";
			this.lbAttr.SelectionMode = System.Windows.Forms.SelectionMode.None;
			this.lbAttr.Size = new System.Drawing.Size(128, 119);
			this.lbAttr.TabIndex = 54;
			// 
			// lblCustAttributes
			// 
			this.lblCustAttributes.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.lblCustAttributes.Location = new System.Drawing.Point(8, 352);
			this.lblCustAttributes.Name = "lblCustAttributes";
			this.lblCustAttributes.Size = new System.Drawing.Size(384, 56);
			this.lblCustAttributes.TabIndex = 53;
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(8, 176);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(80, 23);
			this.label9.TabIndex = 52;
			this.label9.Text = "Attributes:";
			// 
			// lblCanWrite
			// 
			this.lblCanWrite.Location = new System.Drawing.Point(96, 144);
			this.lblCanWrite.Name = "lblCanWrite";
			this.lblCanWrite.Size = new System.Drawing.Size(64, 23);
			this.lblCanWrite.TabIndex = 61;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 144);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(80, 23);
			this.label2.TabIndex = 60;
			this.label2.Text = "Can Write";
			// 
			// lblGetMethod
			// 
			this.lblGetMethod.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.lblGetMethod.Location = new System.Drawing.Point(240, 72);
			this.lblGetMethod.Name = "lblGetMethod";
			this.lblGetMethod.Size = new System.Drawing.Size(152, 64);
			this.lblGetMethod.TabIndex = 62;
			// 
			// lblSetMethod
			// 
			this.lblSetMethod.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.lblSetMethod.Location = new System.Drawing.Point(240, 144);
			this.lblSetMethod.Name = "lblSetMethod";
			this.lblSetMethod.Size = new System.Drawing.Size(152, 64);
			this.lblSetMethod.TabIndex = 63;
			// 
			// lblSet
			// 
			this.lblSet.Location = new System.Drawing.Point(168, 144);
			this.lblSet.Name = "lblSet";
			this.lblSet.Size = new System.Drawing.Size(64, 23);
			this.lblSet.TabIndex = 65;
			this.lblSet.Text = "Set Method";
			// 
			// lblGet
			// 
			this.lblGet.Location = new System.Drawing.Point(168, 72);
			this.lblGet.Name = "lblGet";
			this.lblGet.Size = new System.Drawing.Size(64, 23);
			this.lblGet.TabIndex = 64;
			this.lblGet.Text = "Get Method";
			// 
			// lblType
			// 
			this.lblType.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.lblType.Location = new System.Drawing.Point(96, 8);
			this.lblType.Name = "lblType";
			this.lblType.Size = new System.Drawing.Size(296, 24);
			this.lblType.TabIndex = 67;
			// 
			// lblReturnTypeLabel
			// 
			this.lblReturnTypeLabel.Location = new System.Drawing.Point(8, 8);
			this.lblReturnTypeLabel.Name = "lblReturnTypeLabel";
			this.lblReturnTypeLabel.Size = new System.Drawing.Size(80, 24);
			this.lblReturnTypeLabel.TabIndex = 66;
			this.lblReturnTypeLabel.Text = "Type";
			// 
			// PropertyProperties
			// 
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.lblType,
																		  this.lblReturnTypeLabel,
																		  this.lblSet,
																		  this.lblGet,
																		  this.lblSetMethod,
																		  this.lblGetMethod,
																		  this.lblCanWrite,
																		  this.label2,
																		  this.lblCanRead,
																		  this.lblIsSpecialName,
																		  this.label5,
																		  this.label4,
																		  this.label8,
																		  this.lbAttr,
																		  this.lblCustAttributes,
																		  this.label9});
			this.Name = "PropertyProperties";
			this.Size = new System.Drawing.Size(400, 408);
			this.ResumeLayout(false);

		}
		#endregion
		#endregion

		/// <summary>
		/// Initialize property page.
		/// </summary>
		private void Init()
		{
			lblIsSpecialName.Text = m_Property.IsSpecialName.ToString();
			lblType.Text = m_Property.PropertyType.ToString();
			bool b = m_Property.CanRead;
			lblGet.Visible = b;
			lblCanRead.Text = b.ToString();
			lblGetMethod.Text = (b) ? m_Property.GetGetMethod(true).ToString() : String.Empty;

			b = m_Property.CanWrite;
			lblSet.Visible = b;
			lblCanWrite.Text = b.ToString();
			lblSetMethod.Text = (b) ? m_Property.GetSetMethod(true).ToString() : String.Empty;

			// Get Method attributes
			System.Reflection.PropertyAttributes attr = m_Property.Attributes;
			lbAttr.Items.Clear();
			lbAttr.Items.AddRange(Utils.ListAttributes( typeof( System.Reflection.PropertyAttributes ), (int) attr ).Split(','));

			// Get Custom attributes
			Object[] custAttr = m_Property.GetCustomAttributes(true);
			lblCustAttributes.Text = Utils.ListObjects(custAttr);
		}

		/// <summary>
		/// IProperties implementation
		/// </summary>
		/// <param name="val"></param>
		public void SetObject(object val)
		{
			m_Property = (PropertyInfo)val;
			Init();
			this.Visible = true;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Israel Israel
Leon works as Chief Architect at SRL Group. He leads architectural design and development of various enterprise level projects.
You can meet him on user groups, conferences and forums dedicated to Architecture, ASP.NET, Team System etc. or join him for the next white water rafting adventure

Comments and Discussions