Beispiel #1
0
        static void Main2301()
        {
            Console.WriteLine("Hello Visitor Pattern!");

            var objectStructure = new ObjectStructure();
            var concreteNodeA   = new ConcreteNodeA();
            var concreteNodeB   = new ConcreteNodeB();

            objectStructure.Add(concreteNodeA);
            objectStructure.Add(concreteNodeB);

            Console.WriteLine("------------------访问者A访问元素------------------");
            objectStructure.Action(new ConcreteVisitorA());

            Console.WriteLine("------------------访问者B访问元素------------------");
            objectStructure.Action(new ConcreteVisitorB());


            Console.ReadLine();
        }
Beispiel #2
0
 public void Visit(ConcreteNodeA concreteNodeA)
 {
     Console.WriteLine($"Visitor B access the Node A");
 }