Пример #1
0
        static void Main(string[] args)
        {
            Creator[] creators = new Creator[2];

            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();


            // Iterate over creators and create products
            foreach (Creator creator in creators)
            {
                Product product = creator.FactoryMethod();
                Console.WriteLine("Created {0}",
                                  product.GetType().Name);
            }

            Console.ReadKey();


            //test intentando crear factory dinámicos y fuertemente tipados para ser utilizados por diferentes clases (carpeta solidcompliantfactory)
            Creator[] newCreators = new Creator[2];

            newCreators[0] = new ProductACreator();
            newCreators[1] = new ProductBCreator();

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

            Console.ReadKey();
        }
Пример #2
0
		/// <summary>
		/// The entry point of the program, where the program control starts and ends.
		/// </summary>
		/// <param name="args">The command-line arguments.</param>
		public static void Main (string[] args)
		{
			// declare two creators
			Creator creator1 = new ConcreteCreatorA();
			Creator creator2 = new ConcreteCreatorB();

			// create the products
			Product product1 = creator1.FactoryMethod();
			Product product2 = creator2.FactoryMethod();
		}
Пример #3
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            // declare two creators
            Creator creator1 = new ConcreteCreatorA();
            Creator creator2 = new ConcreteCreatorB();

            // create the products
            Product product1 = creator1.FactoryMethod();
            Product product2 = creator2.FactoryMethod();
        }
Пример #4
0
        public static void Main(string[] args)
        {
            Creator[] creators = new Creator[2];
            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();

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

            Console.Read();
        }
Пример #5
0
        static void Main()
        {
            // An array of creators
            Creator[] creators = new Creator[2];
            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();

            // Iterate over creators and create products
            foreach (Creator creator in creators)
            {
                Product product = creator.FactoryMethod();
                Console.WriteLine("Created {0}",
                  product.GetType().Name);
            }

            // Wait for user
            Console.Read();
        }
Пример #6
0
        static void ExecuteExample1()
        {
            // An array of creators

            Creator[] creators = new Creator[2];

            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();

            // Iterate over creators and create products

            foreach (Creator creator in creators)
            {
                Product product = creator.FactoryMethod();
                Console.WriteLine("Created {0}",
                                  product.GetType().Name);
            }
        }
Пример #7
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main(string[] args)
        {
            // An array of creators
            Creator[] creators = new Creator[2];

            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();

            // Iterate over creators and create employees
            foreach (Creator creator in creators)
            {
                Employee employee = creator.FactoryMethod();
                Console.WriteLine("Created {0}",
                                  employee.GetType().Name);
            }

            // Wait for user
            Console.ReadKey();
        }