static void Main(string[] args) { ObjectStructure o = new ObjectStructure(); o.Attach(new ElementA()); o.Attach(new ElementB()); o.Accept(new Visitor1()); o.Accept(new Visitor2()); Console.ReadKey(); }
static void Main() { 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(); }
static void Main(string[] args) { ObjectStructure objectStructure = new ObjectStructure(); objectStructure.Attach(new ConcreteElementA()); objectStructure.Attach(new ConcreteElementB()); ConcreteVisitor1 concreteVisitor1 = new ConcreteVisitor1(); ConcreteVisitor2 concreteVisitor2 = new ConcreteVisitor2(); objectStructure.Accept(concreteVisitor1); objectStructure.Accept(concreteVisitor2); Console.Read(); }
static void Main() { // Setup structure ObjectStructure o = new ObjectStructure(); o.Attach(new ConcreteElementA()); o.Attach(new ConcreteElementB()); // Create visitor objects ConcreteVisitor1 v1 = new ConcreteVisitor1(); ConcreteVisitor2 v2 = new ConcreteVisitor2(); // Structure accepting visitors o.Accept(v1); o.Accept(v2); // Wait for user Console.ReadKey(); }
private static void Main(string[] args) { ObjectStructure obj = new ObjectStructure(); obj.Attach(new Man()); obj.Attach(new Woman()); Success success = new Success(); obj.Display(success); Fail fail = new Fail(); obj.Display(fail); Love love = new Love(); obj.Display(love); Console.Read(); }
public static void Run() { Console.WriteLine("This structural code demonstrates the Visitor pattern in which an object traverses an object structure and performs the same operation on each node in this structure. Different visitor objects define different operations.\n"); 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); /* * ConcreteElementA visited by ConcreteVisitor1 * ConcreteElementB visited by ConcreteVisitor1 * ConcreteElementA visited by ConcreteVisitor2 * ConcreteElementB visited by ConcreteVisitor2 */ }
static void Main(string[] args) { try { ObjectStructure o = new ObjectStructure(); o.Attach(new ConcreteElementA()); o.Attach(new ConcreteElementB()); // Create visitor objects ConcreteVisitor1 v1 = new ConcreteVisitor1(); ConcreteVisitor2 v2 = new ConcreteVisitor2(); // Structure accepting visitors o.Accept(v1); o.Accept(v2); } finally { Console.ReadKey(); } }
private static void Main(string[] args) { // Setup structure ObjectStructure o = new ObjectStructure(); o.Attach(new ConcreteElementA()); o.Attach(new ConcreteElementB()); // Create visitor objects ConcreteVisitor1 v1 = new ConcreteVisitor1(); ConcreteVisitor2 v2 = new ConcreteVisitor2(); // Structure accepting visitors o.Accept(v1); o.Accept(v2); // Wait for user Console.ReadKey(); }
static void Main() { var objectStructure = new ObjectStructure(); objectStructure.Attach(new ConcreteElementA()); objectStructure.Attach(new ConcreteElementB()); objectStructure.Accept(new ConcreteVisitorA()); objectStructure.Accept(new ConcreteVisitorB()); }