private static void Main()
        {
            var creators = new Creator[2];
            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();

            foreach (var product in creators.Select(creator => creator.FactoryMethod()))
            {
                Console.WriteLine($"{product} with class name {product.GetType().Name} created at {DateTime.Now}");
            }
        }
Exemple #2
0
        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.ReadKey();
        }
Exemple #3
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // An array of creators
            var creators = new Creator[2];

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

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

            // Wait for user
            Console.ReadKey();
        }
Exemple #4
0
 // The client code works with an instance of a concrete creator, albeit
 // through its base interface. As long as the client keeps working with
 // the creator via the base interface, you can pass it any creator's
 // subclass.
 public void ClientCode(Creator creator)
 {
     Console.WriteLine("Client: I'm not aware of the creator's class," +
                       "but it still works.\n" + creator.SomeOperation());
 }
Exemple #5
0
 public void ClientCode(Creator creator)
 {
     System.Console.WriteLine("client: I am not aware of the creator class but is stil works " + creator.SomeOperation());
 }
Exemple #6
0
 public void ClientCode(Creator creator)
 {
     Result = creator.SomeOperation();
 }
Exemple #7
0
 static void LaunchVehicle(Creator creator)
 {
     Console.WriteLine(creator.Launch());
 }