Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            #region Prototype

            Abstraction ab = new RefinedAbstraction();

            ab.SetImplementor(new ConcreteImplementorA());
            ab.Operation();

            ab.SetImplementor(new ConcreteImplementorB());
            ab.Operation();

            Console.WriteLine();

            #endregion Prototype

            HandsetBrand handsetBrand = new HandsetBrandM();
            handsetBrand.SetHandsetSoft(new HandsetMp3());
            handsetBrand.Run();
            handsetBrand.SetHandsetSoft(new HandsetGame());
            handsetBrand.Run();

            handsetBrand = new HandsetBrandN();
            handsetBrand.SetHandsetSoft(new HandsetAddressList());
            handsetBrand.Run();

            Console.ReadLine();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 桥接模式
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            //HandsetBrand ab;
            //ab = new Android();
            //ab.SetHandsetSoft(new HansetGame());
            //ab.Run();

            //ab.SetHandsetSoft(new HansetAddresslist());
            //ab.Run();

            //ab = new Ios();
            //ab.SetHandsetSoft(new HansetGame());
            //ab.Run();

            //ab.SetHandsetSoft(new HansetAddresslist());
            //ab.Run();
            #region demo
            var ab = new RefinedAbstraction();
            ab.SetImplementor(new ConcretelmplementorA());
            ab.Operation();
            ab.SetImplementor(new ConcretelmplementorB());
            ab.Operation();
            Console.Read();
            #endregion
            Console.Read();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Abstraction operatorObj = new RefinedAbstraction();

            operatorObj.SetImplementor(new ConcreteImplementorA());
            operatorObj.Operation();
            operatorObj.SetImplementor(new ConcreteImplementorB());
            operatorObj.Operation();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Abstraction ab = new RefinedAbstraction();

            ab.SetImplementor(new ConcreteImplementorA());
            ab.Operation();
            ab.SetImplementor(new ConcerteImplementorB());
            ab.Operation();
            Console.Read();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            try
            {
                {//BasicStructure
                    Abstraction abstraction = new RefinedAbstraction();
                    abstraction.SetImplementor(new ConcreteImplementorA());
                    abstraction.Operation();
                }
                {//SituationSimulation
                    HandsetBrand huawei = new Huawei();
                    huawei.SetHandsetBrand(new HandsetGame());
                    huawei.Run("华为");

                    HandsetBrand xiaomi = new Xiaomi();
                    xiaomi.SetHandsetBrand(new HandsetGame());
                    xiaomi.Run("小米");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
        }
        /// <summary>
        /// 基础例子
        /// </summary>
        public static void BaseSample()
        {
            Abstraction abstraction = new RefinedAbstraction();

            abstraction.SetImplementor(new ConcreteImplementorA());
            abstraction.Operation();
            Console.ReadKey();
        }