Beispiel #1
0
 private static void HandleDepartments(ref Company c, XElement xml)
 {
     var xmlDepts = xml.Elements("Departments");
     foreach (var xElement in xmlDepts.Elements("Department"))
     {
         c.Departments.Add(HandleDepartment(xElement));
     }
 }
Beispiel #2
0
        /// <summary>
        /// Creates company from its XML representation using LINQ2XML for deserialization
        /// </summary>
        /// <returns>In memory company model</returns>
        public static Company CreateCompany(XDocument xmlDoc)
        {
            var company = new Company();

            if (xmlDoc.Root != null)
            {
                var name = xmlDoc.Root.Elements().Where(el => el.Name == "Name").First().Value;
                company.Name = name;
            }

            HandleDepartments(ref company, xmlDoc.Root);

            return company;
        }