Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Delegate Factory

, 10 Jan 2005
A dynamic factory using delegates.
delegatefactory_demo.zip
Objects
Objects.csproj.user
TestFactory
App.ico
TestFactory.csproj.user
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)

Share

About the Author

Asa Meltzer
Software Developer
Israel Israel
Software designer and programmer.
Programming languages:
MFC, C++, Java , C#, VB and sometimes C and assembly.

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 11 Jan 2005
Article Copyright 2005 by Asa Meltzer
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid