Click here to Skip to main content
12,299,570 members (49,497 online)
Click here to Skip to main content

Stats

44.3K views
105 downloads
42 bookmarked
Posted

Delegate Factory

, 10 Jan 2005 CPOL
A dynamic factory using delegates.
using System;

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

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

		#endregion
		
		#region C'tor

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

		#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
Web02 | 2.8.160525.2 | Last Updated 11 Jan 2005
Article Copyright 2005 by Asa Meltzer
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid