Ejemplo n.º 1
0
 private void EmployeeToXml(Employee employee)
 {
   var element = new XElement("Employee",
     new XElement("Name", employee.Name),
     new XElement("Number", employee.RegNumber),
     new XElement("Designation", employee.Designation),
     new XElement("Department", employee.Department)
   );
   Console.WriteLine(element.ToString());
 }
Ejemplo n.º 2
0
 private void EmployeeToText(Employee employee)
 {
   Console.WriteLine("Employee: [Name: {0}, Number:{1}, Designation: {2}, Department: {3}]", employee.Name,
     employee.RegNumber, employee.Designation, employee.Department);
 }
Ejemplo n.º 3
0
    public static void RunVisitor()
    {
      IVisitor xmlVisitor = new XmlVisitor();
      IVisitor textVisitor = new TextVisitor();

      Details detail = new Employee("Bill Gates", "12345", "Bill and Melinda Gates Foundation", "CEO");
      detail.Accept(xmlVisitor);
      detail.Accept(textVisitor);

      detail = new Address("98102", "Seattle", "USA");
      detail.Accept(xmlVisitor);
      detail.Accept(textVisitor);

      detail = new Contact("9243110669", "08041893228", "08041893333");
      detail.Accept(xmlVisitor);
      detail.Accept(textVisitor);
    }