Example #1
0
        public VacationDataSource()
        {
            var       data = EmbeddedResource.GetStream("VacationSpots.Common.Data.VacationData.xml");
            XDocument doc  = XDocument.Load(data);

            if (doc.Root != null)
            {
                foreach (XElement category in doc.Root.Elements("category"))
                {
                    var vacationCategory = new VacationCategory(
                        category.Attribute("id").Value,
                        category.Attribute("title").Value,
                        category.Attribute("subtitle").Value,
                        category.Attribute("image").Value,
                        category.Attribute("description").Value);

                    allCategories.Add(vacationCategory);

                    foreach (XElement trip in category.Elements("destination"))
                    {
                        var item = new VacationItem(
                            trip.Attribute("id").Value,
                            trip.Attribute("title").Value,
                            trip.Attribute("subtitle").Value,
                            trip.Attribute("image").Value, trip.Value)
                        {
                            CategoryOwner = vacationCategory
                        };
                        vacationCategory.Items.Add(item);
                        allVacations.Add(item);
                    }
                }
            }
        }
Example #2
0
        public VacationDataSource()
        {
            XDocument doc = XDocument.Load(@"data/VacationData.xml");

            if (doc != null)
            {
                foreach (XElement category in doc.Root.Elements("category"))
                {
                    VacationCategory vacationCategory = new VacationCategory(
                        category.Attribute("id").Value,
                        category.Attribute("title").Value,
                        category.Attribute("subtitle").Value,
                        category.Attribute("image").Value,
                        category.Attribute("description").Value);

                    _allCategories.Add(vacationCategory);

                    foreach (XElement trip in category.Elements("destination"))
                    {
                        VacationItem item = new VacationItem(
                            trip.Attribute("id").Value,
                            trip.Attribute("title").Value,
                            trip.Attribute("subtitle").Value,
                            trip.Attribute("image").Value, trip.Value)
                        {
                            CategoryOwner = vacationCategory
                        };
                        vacationCategory.Items.Add(item);
                        _allVacations.Add(item);
                    }
                }
            }
        }