abstract class Element { public abstract void Accept(Visitor visitor); } /// <summary> /// A 'ConcreteElement' class /// </summary> class ConcreteElementA : Element { public override void Accept(Visitor visitor) { visitor.VisitConcreteElementA(this); } public void OperationA() { } } /// <summary> /// A 'ConcreteElement' class /// </summary> class ConcreteElementB : Element { public override void Accept(Visitor visitor) { visitor.VisitConcreteElementB(this); } public void OperationB() { } } /// <summary> /// The 'ObjectStructure' class /// </summary> class ObjectStructure { private List<Element> _elements = new List<Element>(); public void Attach(Element element) { _elements.Add(element); } public void Detach(Element element) { _elements.Remove(element); }
http://www.dofactory.com/net/visitor-design-pattern
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)