コード例 #1
0
        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 products

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

            }
            //wait for user input
            Console.Read();
        }
コード例 #2
0
 public void ClientCode(Creator creator)
 {
     Console.WriteLine("Hey client! I am not aware of creator's class, but it still works!!" + creator.SomeOperation());
 }
コード例 #3
0
 public void ClientCode(Creator creator)
 {
     Console.WriteLine("Client: I'm not aware of the creator's class, " + "but it still works.\n" + creator.SomeOperation());
 }