Example #1
0
 private void ContactToXml(Contact contact)
 {
   var element = new XElement("Contact",
     new XElement("Mobile", contact.Mobile),
     new XElement("Office", contact.Office),
     new XElement("Fax", contact.Fax)
   );
   Console.WriteLine(element.ToString());
 }
Example #2
0
 private void ContactToText(Contact contact)
 {
   Console.WriteLine("Contact: [Mobile: {0}, Office:{1}, Fax: {2}]", contact.Mobile, contact.Office, contact.Fax);
 }
Example #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);
    }