Click here to Skip to main content
15,892,005 members
Articles / Programming Languages / XML

Learn How to Build a Provider Framework - With an Easy to Understand Example Towards Applying the Provider Pattern

Rate me:
Please Sign up or sign in to vote.
4.52/5 (43 votes)
20 Jul 2007CPOL14 min read 110.5K   590   154  
After reading this article, you'll be able to: (1) Change your mindset a little bit, and start thinking about 'frameworks' instead of just 'code' (2) Understand a lot about practically applying the Provider pattern in your projects (3) Gain much knowledge regarding XML config files and providers.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using Sumeru.Publisher.Framework;

namespace Sumeru.Publisher.Loader
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button btnLoad;
		private System.Windows.Forms.TextBox txtFileToLoad;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <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 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.txtFileToLoad = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.btnLoad = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// txtFileToLoad
			// 
			this.txtFileToLoad.Location = new System.Drawing.Point(8, 40);
			this.txtFileToLoad.Name = "txtFileToLoad";
			this.txtFileToLoad.Size = new System.Drawing.Size(352, 20);
			this.txtFileToLoad.TabIndex = 0;
			this.txtFileToLoad.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(144, 16);
			this.label1.TabIndex = 1;
			this.label1.Text = "File To Load";
			// 
			// btnLoad
			// 
			this.btnLoad.Location = new System.Drawing.Point(248, 80);
			this.btnLoad.Name = "btnLoad";
			this.btnLoad.Size = new System.Drawing.Size(112, 24);
			this.btnLoad.TabIndex = 2;
			this.btnLoad.Text = "Load";
			this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(370, 130);
			this.Controls.Add(this.btnLoad);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txtFileToLoad);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
			this.Name = "Form1";
			this.Text = "Loader";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
            this.txtFileToLoad.Text = Application.StartupPath + "\\PluginConfig.xml";
		}

		private void btnLoad_Click(object sender, System.EventArgs e)
		{
			PublisherLoader pl=new PublisherLoader();
			pl.LoadPublisher(this.txtFileToLoad.Text);
		}
	}
}

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
Architect
India India
Architect, Developer, Speaker | Wannabe GUT inventor & Data Scientist | Microsoft MVP in C#

Comments and Discussions