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

Delegate Factory

Rate me:
Please Sign up or sign in to vote.
2.92/5 (8 votes)
10 Jan 2005CPOL3 min read 58.4K   165   43  
A dynamic factory using delegates
using System;

namespace Objects
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	public class Class2 : AObject
	{
		#region Constants

		/// <summary>
		/// The class type identifier.
		/// </summary>
		public const Int32 ClassType = 2;

		#endregion

		
		#region C'tor

		/// <summary>
		/// Default C'tor.
		/// </summary>
		internal Class2()
		{
			this.m_nType = ClassType;
		}

		#endregion

		#region Overrides

		/// <summary>
		/// Implementation of Print.
		/// </summary>
		public override void Print()
		{
			String msg = String.Format("Class: {0, 20} Value: {1, 10}", ToString(), m_nType*56);
			Console.WriteLine(msg);
		}

		#endregion

		#region Static

		/// <summary>
		/// A handler function for the factory to create objects;
		/// </summary>
		/// <param name="list">The parameter list.</param>
		/// <returns>A Class2 object.</returns>
		public static AObject ObjectCreator(params object[] list)
		{
			return new Class2();
		}

		#endregion
	}
}

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
Israel Israel
Software designer and programmer.
Programming languages:
MFC, C++, Java , C#, VB and sometimes C and assembly.

Comments and Discussions