Click here to Skip to main content
15,891,431 members
Articles / Desktop Programming / Windows Forms

Dependency Injection Pattern (Loose Coupling)

Rate me:
Please Sign up or sign in to vote.
2.82/5 (6 votes)
1 May 2008CPOL2 min read 40.5K   413   11  
Description of Dependency Injection Pattern
namespace Dependency.Injection
{
	partial class ExampleDisplay
	{
		/// <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()
		{
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExampleDisplay));
			this.lblCost = new System.Windows.Forms.Label();
			this.txtNumberOfAnimals = new System.Windows.Forms.TextBox();
			this.btnSheepDIConstructor = new System.Windows.Forms.Button();
			this.cmbAnimals = new System.Windows.Forms.ComboBox();
			this.btnSetterDI = new System.Windows.Forms.Button();
			this.btnInterfaceDI = new System.Windows.Forms.Button();
			this.btnMoroccanInvestor = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// lblCost
			// 
			this.lblCost.AutoSize = true;
			this.lblCost.Location = new System.Drawing.Point(21, 51);
			this.lblCost.Name = "lblCost";
			this.lblCost.Size = new System.Drawing.Size(122, 13);
			this.lblCost.TabIndex = 1;
			this.lblCost.Text = "Enter Number of animals";
			// 
			// txtNumberOfAnimals
			// 
			this.txtNumberOfAnimals.Location = new System.Drawing.Point(24, 87);
			this.txtNumberOfAnimals.Name = "txtNumberOfAnimals";
			this.txtNumberOfAnimals.Size = new System.Drawing.Size(176, 20);
			this.txtNumberOfAnimals.TabIndex = 2;
			this.txtNumberOfAnimals.Text = "0";
			// 
			// btnSheepDIConstructor
			// 
			this.btnSheepDIConstructor.Location = new System.Drawing.Point(24, 228);
			this.btnSheepDIConstructor.Name = "btnSheepDIConstructor";
			this.btnSheepDIConstructor.Size = new System.Drawing.Size(201, 23);
			this.btnSheepDIConstructor.TabIndex = 3;
			this.btnSheepDIConstructor.Text = "Constructor dependency injection";
			this.btnSheepDIConstructor.UseVisualStyleBackColor = true;
			this.btnSheepDIConstructor.Click += new System.EventHandler(this.btnSheepDIConstructor_Click);
			// 
			// cmbAnimals
			// 
			this.cmbAnimals.FormattingEnabled = true;
			this.cmbAnimals.Items.AddRange(new object[] {
            "Cow",
            "Sheep"});
			this.cmbAnimals.Location = new System.Drawing.Point(404, 87);
			this.cmbAnimals.Name = "cmbAnimals";
			this.cmbAnimals.Size = new System.Drawing.Size(121, 21);
			this.cmbAnimals.TabIndex = 4;
			// 
			// btnSetterDI
			// 
			this.btnSetterDI.Location = new System.Drawing.Point(24, 272);
			this.btnSetterDI.Name = "btnSetterDI";
			this.btnSetterDI.Size = new System.Drawing.Size(201, 23);
			this.btnSetterDI.TabIndex = 5;
			this.btnSetterDI.Text = "Setter dependency injection";
			this.btnSetterDI.UseVisualStyleBackColor = true;
			this.btnSetterDI.Click += new System.EventHandler(this.btnSetterDI_Click);
			// 
			// btnInterfaceDI
			// 
			this.btnInterfaceDI.Location = new System.Drawing.Point(324, 228);
			this.btnInterfaceDI.Name = "btnInterfaceDI";
			this.btnInterfaceDI.Size = new System.Drawing.Size(201, 23);
			this.btnInterfaceDI.TabIndex = 6;
			this.btnInterfaceDI.Text = "Canadian  Investor DI injection";
			this.btnInterfaceDI.UseVisualStyleBackColor = true;
			this.btnInterfaceDI.Click += new System.EventHandler(this.btnInterfaceDI_Click);
			// 
			// btnMoroccanInvestor
			// 
			this.btnMoroccanInvestor.Location = new System.Drawing.Point(324, 272);
			this.btnMoroccanInvestor.Name = "btnMoroccanInvestor";
			this.btnMoroccanInvestor.Size = new System.Drawing.Size(201, 23);
			this.btnMoroccanInvestor.TabIndex = 7;
			this.btnMoroccanInvestor.Text = "Moroccan Investor DI injection";
			this.btnMoroccanInvestor.UseVisualStyleBackColor = true;
			this.btnMoroccanInvestor.Click += new System.EventHandler(this.btnMoroccanInvestor_Click);
			// 
			// ExampleDisplay
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(560, 360);
			this.Controls.Add(this.btnMoroccanInvestor);
			this.Controls.Add(this.btnInterfaceDI);
			this.Controls.Add(this.btnSetterDI);
			this.Controls.Add(this.cmbAnimals);
			this.Controls.Add(this.btnSheepDIConstructor);
			this.Controls.Add(this.txtNumberOfAnimals);
			this.Controls.Add(this.lblCost);
			this.Name = "ExampleDisplay";
			this.Text = "Farm Investor";
			this.ResumeLayout(false);
			this.PerformLayout();

		}

		#endregion

		private System.Windows.Forms.Label lblCost;
		private System.Windows.Forms.TextBox txtNumberOfAnimals;
		private System.Windows.Forms.Button btnSheepDIConstructor;
		private System.Windows.Forms.ComboBox cmbAnimals;
		private System.Windows.Forms.Button btnSetterDI;
		private System.Windows.Forms.Button btnInterfaceDI;
		private System.Windows.Forms.Button btnMoroccanInvestor;
	}
}

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
Canada Canada
Education:
Master.CS
Bachelor.CIS
MCTS -- BizTalk Server

Sport:
Favorite teams are:
1) Atlas lions of morocco (soccer)
2) Canadians of Montreal (Hockey)




Comments and Discussions