示例#1
0
        /// <summary>
        /// The visitor test.
        /// </summary>
        public static void VisitorTest()
        {
            Element elementA = new ConcreteElementA();
            Element elementB = new ConcreteElementB();

            Visitor visitorA = new ConcreteVisitorA();
            Visitor visitorB = new ConcreteVisitorB();

            var structure = new ObjectStructure();

            structure.Attach(elementA);
            structure.Attach(elementB);
            structure.Accept(visitorA);
            structure.Accept(visitorB);

            structure.Detach(elementA);
            structure.Accept(visitorA);
            structure.Accept(visitorB);

            Console.WriteLine("VisitorTest finish.");
        }
示例#2
0
 /// <summary>
 /// The visit concrete element a.
 /// </summary>
 /// <param name="concreteElementA">
 /// The concrete element a.
 /// </param>
 public override void VisitConcreteElementA(ConcreteElementA concreteElementA)
 {
     Console.WriteLine("Element:{0} visited by {1}", concreteElementA.GetType().Name, this.GetType().Name);
 }
示例#3
0
 /// <summary>
 /// The visit concrete element a.
 /// </summary>
 /// <param name="concreteElementA">
 /// The concrete element a.
 /// </param>
 public abstract void VisitConcreteElementA(ConcreteElementA concreteElementA);