Exemplo n.º 1
0
        //客户端代码
        static void Main(string[] args)
        {
            ObjectStrcture o = new ObjectStrcture();

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

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

            o.Accept(v1);
            o.Accept(v2);
        }
Exemplo n.º 2
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.Read();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            ObjectStructure objectStructure = new ObjectStructure();

            objectStructure.Add(new ConcreteElement1());
            objectStructure.Add(new ConcreteElement2());

            Visitor visitor = new ConcreteVisitor1();

            objectStructure.accept(visitor);

            visitor = new ConcreteVisitor2();
            objectStructure.accept(visitor);

            Console.Read();
        }