Click here to Skip to main content
15,886,026 members
Articles / Programming Languages / C#

Xmi CodeDom Library, Part 2 - Using dynamic types to increase performance

Rate me:
Please Sign up or sign in to vote.
4.11/5 (5 votes)
30 May 2006CPOL10 min read 42.5K   543   18  
A .Net 2.0 library that converts XMI into CodeDom. Part 2 shows how CodeDom was used to create dynamic types to outperform the reflection-based parsing.
namespace XmiTestApp
{ 
    partial class MainForm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form 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.label1 = new System.Windows.Forms.Label();
        	this.txtXmiFilename = new System.Windows.Forms.TextBox();
        	this.btnBrowse = new System.Windows.Forms.Button();
        	this.label2 = new System.Windows.Forms.Label();
        	this.cboOutputType = new System.Windows.Forms.ComboBox();
        	this.btnGenerate = new System.Windows.Forms.Button();
        	this.txtCode = new System.Windows.Forms.TextBox();
        	this.treeClasses = new System.Windows.Forms.TreeView();
        	this.label3 = new System.Windows.Forms.Label();
        	this.btnHierarchy = new System.Windows.Forms.Button();
        	this.statusStrip1 = new System.Windows.Forms.StatusStrip();
        	this.statusBarLabel = new System.Windows.Forms.ToolStripStatusLabel();
        	this.progressBar = new System.Windows.Forms.ToolStripProgressBar();
        	this.statusStrip1.SuspendLayout();
        	this.SuspendLayout();
        	// 
        	// label1
        	// 
        	this.label1.AutoSize = true;
        	this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        	this.label1.Location = new System.Drawing.Point(12, 9);
        	this.label1.Name = "label1";
        	this.label1.Size = new System.Drawing.Size(87, 13);
        	this.label1.TabIndex = 0;
        	this.label1.Text = "XMI Filename:";
        	// 
        	// txtXmiFilename
        	// 
        	this.txtXmiFilename.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
        	        	        	| System.Windows.Forms.AnchorStyles.Right)));
        	this.txtXmiFilename.Location = new System.Drawing.Point(106, 9);
        	this.txtXmiFilename.Name = "txtXmiFilename";
        	this.txtXmiFilename.Size = new System.Drawing.Size(603, 20);
        	this.txtXmiFilename.TabIndex = 1;
        	this.txtXmiFilename.TextChanged += new System.EventHandler(this.TxtXmiFilenameTextChanged);
        	// 
        	// btnBrowse
        	// 
        	this.btnBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
        	this.btnBrowse.Location = new System.Drawing.Point(715, 9);
        	this.btnBrowse.Name = "btnBrowse";
        	this.btnBrowse.Size = new System.Drawing.Size(75, 23);
        	this.btnBrowse.TabIndex = 2;
        	this.btnBrowse.Text = "Browse";
        	this.btnBrowse.UseVisualStyleBackColor = true;
        	this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
        	// 
        	// label2
        	// 
        	this.label2.AutoSize = true;
        	this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        	this.label2.Location = new System.Drawing.Point(12, 43);
        	this.label2.Name = "label2";
        	this.label2.Size = new System.Drawing.Size(81, 13);
        	this.label2.TabIndex = 3;
        	this.label2.Text = "Output Type:";
        	// 
        	// cboOutputType
        	// 
        	this.cboOutputType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
        	this.cboOutputType.FormattingEnabled = true;
        	this.cboOutputType.Location = new System.Drawing.Point(106, 43);
        	this.cboOutputType.Name = "cboOutputType";
        	this.cboOutputType.Size = new System.Drawing.Size(192, 21);
        	this.cboOutputType.TabIndex = 4;
        	// 
        	// btnGenerate
        	// 
        	this.btnGenerate.Location = new System.Drawing.Point(328, 43);
        	this.btnGenerate.Name = "btnGenerate";
        	this.btnGenerate.Size = new System.Drawing.Size(119, 23);
        	this.btnGenerate.TabIndex = 5;
        	this.btnGenerate.Text = "Generate Code";
        	this.btnGenerate.UseVisualStyleBackColor = true;
        	this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click);
        	// 
        	// txtCode
        	// 
        	this.txtCode.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
        	        	        	| System.Windows.Forms.AnchorStyles.Left) 
        	        	        	| System.Windows.Forms.AnchorStyles.Right)));
        	this.txtCode.BackColor = System.Drawing.SystemColors.ControlLightLight;
        	this.txtCode.Location = new System.Drawing.Point(328, 83);
        	this.txtCode.Multiline = true;
        	this.txtCode.Name = "txtCode";
        	this.txtCode.ReadOnly = true;
        	this.txtCode.ScrollBars = System.Windows.Forms.ScrollBars.Both;
        	this.txtCode.Size = new System.Drawing.Size(462, 408);
        	this.txtCode.TabIndex = 6;
        	this.txtCode.WordWrap = false;
        	// 
        	// treeClasses
        	// 
        	this.treeClasses.Location = new System.Drawing.Point(15, 83);
        	this.treeClasses.Name = "treeClasses";
        	this.treeClasses.Size = new System.Drawing.Size(307, 408);
        	this.treeClasses.TabIndex = 7;
        	// 
        	// label3
        	// 
        	this.label3.AutoSize = true;
        	this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        	this.label3.Location = new System.Drawing.Point(12, 67);
        	this.label3.Name = "label3";
        	this.label3.Size = new System.Drawing.Size(99, 13);
        	this.label3.TabIndex = 8;
        	this.label3.Text = "Class Hierarchy:";
        	// 
        	// btnHierarchy
        	// 
        	this.btnHierarchy.Location = new System.Drawing.Point(453, 43);
        	this.btnHierarchy.Name = "btnHierarchy";
        	this.btnHierarchy.Size = new System.Drawing.Size(119, 23);
        	this.btnHierarchy.TabIndex = 9;
        	this.btnHierarchy.Text = "View Class Hierarchy";
        	this.btnHierarchy.UseVisualStyleBackColor = true;
        	this.btnHierarchy.Click += new System.EventHandler(this.btnHierarchy_Click);
        	// 
        	// statusStrip1
        	// 
        	this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        	        	        	this.statusBarLabel,
        	        	        	this.progressBar});
        	this.statusStrip1.Location = new System.Drawing.Point(0, 494);
        	this.statusStrip1.Name = "statusStrip1";
        	this.statusStrip1.Size = new System.Drawing.Size(802, 22);
        	this.statusStrip1.TabIndex = 10;
        	this.statusStrip1.Text = "statusStrip1";
        	// 
        	// statusBarLabel
        	// 
        	this.statusBarLabel.AutoSize = false;
        	this.statusBarLabel.Name = "statusBarLabel";
        	this.statusBarLabel.Size = new System.Drawing.Size(350, 17);
        	this.statusBarLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
        	// 
        	// progressBar
        	// 
        	this.progressBar.Name = "progressBar";
        	this.progressBar.Size = new System.Drawing.Size(100, 16);
        	this.progressBar.Visible = false;
        	// 
        	// MainForm
        	// 
        	this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        	this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        	this.ClientSize = new System.Drawing.Size(802, 516);
        	this.Controls.Add(this.statusStrip1);
        	this.Controls.Add(this.btnHierarchy);
        	this.Controls.Add(this.label3);
        	this.Controls.Add(this.treeClasses);
        	this.Controls.Add(this.txtCode);
        	this.Controls.Add(this.btnGenerate);
        	this.Controls.Add(this.cboOutputType);
        	this.Controls.Add(this.label2);
        	this.Controls.Add(this.btnBrowse);
        	this.Controls.Add(this.txtXmiFilename);
        	this.Controls.Add(this.label1);
        	this.MinimumSize = new System.Drawing.Size(372, 229);
        	this.Name = "MainForm";
        	this.Text = "Xmi - CodeDom Converter";
        	this.statusStrip1.ResumeLayout(false);
        	this.statusStrip1.PerformLayout();
        	this.ResumeLayout(false);
        	this.PerformLayout();
        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox txtXmiFilename;
        private System.Windows.Forms.Button btnBrowse;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.ComboBox cboOutputType;
        private System.Windows.Forms.Button btnGenerate;
        private System.Windows.Forms.TextBox txtCode;
        private System.Windows.Forms.TreeView treeClasses;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Button btnHierarchy;
        private System.Windows.Forms.StatusStrip statusStrip1;
        private System.Windows.Forms.ToolStripStatusLabel statusBarLabel;
        protected System.Windows.Forms.ToolStripProgressBar progressBar;
    }
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Microsoft
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions