public static void Main(string[] args)
        {
            string separator = "-------------------------------------------";

            ICreator creator = new Creator();

            Console.WriteLine(creator.ABusinessOperation(0));

            Console.WriteLine();

            Console.WriteLine(creator.ABusinessOperation(1));

            Console.WriteLine();

            Console.WriteLine(creator.ABusinessOperation(2));

            Console.WriteLine(separator);

            ICreator concreteCreator = new ConcreteCreator();

            Console.WriteLine(concreteCreator.ABusinessOperation(0));

            Console.WriteLine();

            Console.WriteLine(concreteCreator.ABusinessOperation(1));

            Console.WriteLine();

            Console.WriteLine(concreteCreator.ABusinessOperation(2));
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            // An array of creators

            ICreator[] creators = new ICreator[1];

            creators[0] = new ConcreteCreator();

            // Iterate over creators and create products

            foreach (ICreator creator in creators)
            {
                ConcreteProduct product = creator.FactoryMethod();
                Console.WriteLine("Created {0}",
                                  product.GetType().Name);
            }

            // Wait for user

            Console.ReadKey();
        }