Ejemplo n.º 1
0
        /// <summary>
        /// 抽象工厂+简单工厂
        /// </summary>
        static void AbstractFactoryWithSimpleFactory()
        {
            //创建抽象工厂
            IFactory factory = new CommonFactory();
            //IFactory factory = new RazeFactory();

            //通过工厂生产产品实体
            IMouse    mouse    = factory.CreateMouse();
            IKeyBoard keyboard = factory.CreateKeyboard();

            Console.WriteLine($"抽象工厂+简单工厂{Environment.NewLine}-------------------------------------------");
            Console.WriteLine($"当前工厂生产的鼠标是:{mouse.GetBrand()}");
            Console.WriteLine($"当前工厂生产的键盘是:{keyboard.GetBrand()}");
            Console.ReadKey();
        }