private void RunFactoryMethodTest() { Creator creator = new ConcreteCreatorA(); FactoryMethodPattern.Product Item1 = creator.FactoryMethod(); creator = new ConcreteCreatorB(); FactoryMethodPattern.Product Item2 = creator.FactoryMethod(); }
public static void MainDemo(string[] args) { // FactoryMethod returns ProductA Creator c = new ConcreteCreatorA(); Product p = c.FactoryMethod(); Console.WriteLine("Created {0}", p); // FactoryMethod returns ProductB c = new ConcreteCreatorB(); p = c.FactoryMethod(); Console.WriteLine("Created {0}", p); }
static void Main(string[] args) { AbstractCreator creatorA = new ConcreteCreatorA(); IProduct productA = creatorA.FactoryMethod(); productA.Launch(); AbstractCreator creatorB = new ConcreteCreatorB(); IProduct productB = creatorB.FactoryMethod(); productB.Launch(); Console.Read(); }