public void Load() { XDocument doc = XDocument.Load(DATA_FILE); // @todo pozor na double tecku v longitude apod. InitData(); XElement elPersons = doc.Root.Element("Persons"); foreach (XElement elPerson in elPersons.Elements("Person")) { Person person = new Person(); person.SetXElement(elPerson); Persons.Add(person); } XElement elPlaces = doc.Root.Element("Places"); foreach (XElement elPlace in elPlaces.Elements("Place")) { Place place = new Place(); place.SetXElement(elPlace); Places.Add(place); } XElement elActionItems = doc.Root.Element("ActionItems"); foreach (XElement elActionItem in elActionItems.Elements("ActionItem")) { switch (elActionItem.Element("Type").Value) { case "debt": Debt debt = new Debt(); debt.SetXElement(elActionItem, this); Debts.Add(debt); break; case "income": Income income = new Income(); income.SetXElement(elActionItem, this); Incomes.Add(income); break; case "loan": Loan loan = new Loan(); loan.SetXElement(elActionItem, this); Loans.Add(loan); break; case "payment": Payment payment = new Payment(); payment.SetXElement(elActionItem, this); Payments.Add(payment); break; case "withdraw": Withdraw withdraw = new Withdraw(); withdraw.SetXElement(elActionItem, this); Withdraws.Add(withdraw); break; } } }