void Main() { var structure = new ObjectStructure(); structure.Add(new ElementA()); structure.Add(new ElementB()); structure.Accept(new ConcreteVisitor1()); structure.Accept(new ConcreteVisitor2()); }
public UseCase() { ObjectStructure structure = new ObjectStructure(); structure.Add(new ConcreteElementOne()); structure.Add(new ConcreteElementTwo()); structure.Accept(new ConcreteVisitorOne()); structure.Accept(new ConcreteVisitorTwo()); }
static void VisitorExample() { var structure = new ObjectStructure(); structure.Add(new ConcreteElement1()); structure.Add(new ConcreteElement2()); structure.Add(new ConcreteElement1()); structure.Accept(new ConcreteVisitor()); }
private static void Main() { var structure = new ObjectStructure(); structure.Add(new ElementA()); structure.Add(new ElementB()); structure.Accept(new Visitor1()); structure.Accept(new Visitor2()); Console.ReadKey(); }
static void Main(string[] args) { ObjectStructure objectStructure = new ObjectStructure(); objectStructure.Add(new ConcreteElementA()); objectStructure.Add(new ConcreteElementB()); ConcreteVisitor1 cea = new ConcreteVisitor1(); ConcreteVisitor2 ceb = new ConcreteVisitor2(); objectStructure.Accept(cea); objectStructure.Accept(ceb); Console.ReadKey(); }
static void Main(string[] args) { var o = new ObjectStructure(); o.Add(new ConcreteElementA()); o.Add(new ConcreteElementB()); o.Add(new ConcreteElementB()); o.Delete(new ConcreteElementB()); var v1 = new ConcreteVisitor1(); var v2 = new ConcreteVisitor2(); o.Accept(v1); o.Accept(v2); Console.ReadKey(); }
static void Main() { var o = new ObjectStructure(); o.Add(new ConcreteElementA("A1")); o.Add(new ConcreteElementA("A2")); o.Add(new ConcreteElementB("B1")); o.Add(new ConcreteElementA("A3")); o.Add(new ConcreteElementB("B2")); var visitor1 = new ConcreteVisitor1(); o.Accept(visitor1); Console.ReadKey(); }
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(); }
static void Main(string[] args) { // base implementation var structure = new ObjectStructure(); structure.Add(new ElementA()); structure.Add(new ElementB()); structure.Accept(new ConcreteVisitor1()); structure.Accept(new ConcreteVisitor2()); //--------------------------------- doubleDespetcher.Visitor v = new doubleDespetcher.Visitor(); Graphic g = new Dot(); // Метод accept() – переопределен, но не перегружен. А значит, связан // динамически. Поэтому реализация `accept` будет выбрана во время выполнения // уже из того класса, объект которого его вызвал (класс Dot). g.accept(v); //--------------------- Console.WriteLine("Bank sample: "); testReal(); Console.ReadLine(); }