Click here to Skip to main content
11,719,816 members (91,740 online)
Click here to Skip to main content
Add your own
alternative version

Delegate Factory

, 10 Jan 2005 CPOL 42.7K 95 42
A dynamic factory using delegates.
delegatefactory_demo.zip
Objects
Objects.csproj.user
TestFactory
App.ico
TestFactory.csproj.user
using System;
using Objects;

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

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

		#endregion

		#region C'tor

		/// <summary>
		/// Default C'tor.
		/// </summary>
		internal Class3()
		{
			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*23);
			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 Class3 object.</returns>
		public static AObject ObjectCreator(params object[] list)
		{
			return new Class3();
		}

		#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.

You may also be interested in...

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