private static void Test() { _firstFactory = new FirstFactory((string Text) => Console.WriteLine(Text)); _secondFactory = new SecondFactory((string Text) => Console.WriteLine(Text)); IProductA firstProductA = _firstFactory.CreateA(); IProductA secondProductA = _secondFactory.CreateA(); IProductB firstProductB = _firstFactory.CreateB(); IProductB secondProductB = _secondFactory.CreateB(); firstProductA.OperationA(); firstProductB.OperationB(); secondProductA.OperationA(); secondProductB.OperationB(); }
static void TestAbstractFabric() { Console.Write("Select category first or second:"); int category = int.Parse(Console.ReadLine()); IAbstractFactory factory; if (category == 1) { factory = new FactoryFirstClass(); } else { factory = new FactorySecondClass(); } IProductA productA = factory.CreateProductA(); IProductB productB = factory.CreateProductB(); Console.WriteLine(productA.OperationA()); Console.WriteLine(productB.OperationB()); Console.WriteLine(productB.OperationWithProductA(productA)); }