/// <summary>
        /// 访问者模式
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            var o = new ObjectStructure();

            o.Attach(new Man());
            o.Attach(new Woman());

            o.Display(new Success());
            o.Display(new Failing());
            o.Display(new Amativeness());

            Console.Read();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            ObjectStructure objectStructure = new ObjectStructure();

            objectStructure.Add(new ConcreteElementA());
            objectStructure.Add(new ConcreteElementB());

            Visitor visitor1 = new ConcreteVisitorA();
            Visitor visitor2 = new ConcreteVisitorB();

            objectStructure.Accept(visitor1);
            objectStructure.Accept(visitor2);
            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            ObjectStructure o = new ObjectStructure();

            o.Attach(new ConcreteElementA());
            o.Attach(new ConcreteElementB());

            ConcreteVisitor1 v1 = new ConcreteVisitor1();
            ConcreteVisitor2 v2 = new ConcreteVisitor2();

            o.Accept(v1);
            o.Accept(v2);

            Console.ReadKey();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var structure = new ObjectStructure();

            structure.Add(new FirstElement());
            structure.Add(new SecondElement());

            var firstVisitor  = new FirstVisitor();
            var secondVisitor = new SecondVisitor();

            structure.Accept(firstVisitor);
            LogHelper.LogSeparator();
            structure.Accept(secondVisitor);

            Console.ReadLine();
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            //Setup structure
            ObjectStructure os = new ObjectStructure();

            os.Attach(new ConcreteElementA());
            os.Attach(new ConcreteElementB());

            //Create visitor objects
            ConcreteVisitor1 visitor1 = new ConcreteVisitor1();
            ConcreteVisitor2 visitor2 = new ConcreteVisitor2();

            //Strucuture accepting visitors
            os.Accept(visitor1);
            os.Accept(visitor2);


            Console.ReadLine();
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            ObjectStructure obj = new ObjectStructure();

            obj.Attach(new ConcreteElementA());
            obj.Attach(new ConcreteElementB());
            ConcreteVisitor visitor = new ConcreteVisitor();

            obj.Accept(visitor);

            ReportManager reportManager = new ReportManager();

            reportManager.Attach(new FinancialReport());
            reportManager.Attach(new LogisticsReport());

            FinanceDirector financeDirector = new FinanceDirector();
            SaleDirector    saleDirector    = new SaleDirector();

            reportManager.Accept(financeDirector);
            reportManager.Accept(saleDirector);
        }
Beispiel #7
0
        public static void Main(string[] args)
        {
            #region Prototype

            var o = new ObjectStructure();
            o.Attach(new ConcreteElementA());
            o.Attach(new ConcreteElementB());
            o.Accept(new ConcreteVisitor1());
            o.Accept(new ConcreteVisitor2());

            Console.WriteLine();

            #endregion Prototype

            var personStructure = new PersonStructure();
            personStructure.Attact(new Man());
            personStructure.Attact(new Woman());

            personStructure.Display(new Success());
            personStructure.Display(new Fail());
            personStructure.Display(new Marriage());

            Console.ReadLine();
        }