Пример #1
0
        public XDocument GetXML()
        {
            var xDocument   = new XDocument();
            var xElement    = new XElement("Students");
            var xAttributes = StudentDataProvider.GetData()
                              .Select(s => new XElement("Student",
                                                        new XAttribute("Id", s.Id),
                                                        new XAttribute("Name", s.Name),
                                                        new XAttribute("Email", s.Email)));

            xElement.Add(xAttributes);
            xDocument.Add(xElement);
            return(xDocument);
        }
Пример #2
0
        //Without Adapter Pattern
        public static void Main__(string[] args)
        {
            var xml = new XmlConverter();

            Console.WriteLine(xml.GetXML());

            Console.WriteLine();

            var students = StudentDataProvider.GetData();
            var json     = new JsonConverter(students);

            Console.WriteLine(json.ToJson());

            Console.ReadKey();
        }