Esempio n. 1
0
        // "Visitor"

        // "ConcreteVisitor1"
        public void TestVisitorPattern()
        {
            // Setup structure

            Element aE = new ConcreteElementA();
            Element bE = new ConcreteElementB();
            var     o  = new ObjectStructure();

            o.Attach(aE);
            o.Attach(bE);


            // Create visitor objects
            var v1 = new ConcreteVisitor1();
            var v2 = new ConcreteVisitor2();

            // Structure accepting visitors
            o.Accept(v1);
            o.Accept(v2);

            o.Detach(aE);
            o.Detach(bE);
            // Wait for user
            Console.Read();
        }