Click here to Skip to main content
15,883,623 members
Articles / Programming Languages / C#

Generic Abstract Factory

Rate me:
Please Sign up or sign in to vote.
4.71/5 (29 votes)
22 Apr 2014CPOL6 min read 91.9K   1.2K   75  
Generic Abstract Factory Design Pattern
using System;
using System.Collections.Generic;
using System.Text;

namespace GenericAbstractFactory.Common
{
    class Plane : IFactory<Plane>
    {
        public TProduct Build<TProduct>() where TProduct : IProduct<Plane>, new()
        {
            Console.WriteLine("Creating Plane: " + typeof(TProduct));
            return new TProduct();
        }
    }
}

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
Team Leader
United States United States
Jon Pajela is a Principal Software Engineer in Denver, Colorado. He holds the following qualifications:

Master of Science in Information Management (Dean's Lister)
Bachelor of Science in Mathematics major in Computer Science

MCAD C# .NET - Microsoft Certified Application Developer for C# .NET
SCJP - Sun Certified Java Programmer

Comments and Discussions