Exemplo n.º 1
0
        List <OlympicMedals> LoadDataFromXML()
        {
            XDocument            document = DataLoader.LoadXDocumentFromResources("/Data/OlympicMedals2014.xml");
            List <OlympicMedals> infos    = new List <OlympicMedals>();

            if (document != null)
            {
                foreach (XElement element in document.Element("ArrayOfOlympicMedals").Elements())
                {
                    OlympicMedals medal = new OlympicMedals();
                    medal.Country       = element.Element("Country").Value;
                    medal.SportCategory = element.Element("SportCategory").Value;
                    medal.MedalType     = element.Element("MedalType").Value;
                    medal.Count         = Convert.ToInt32(element.Element("Count").Value);
                    medal.Athletes      = GetAthletes(element.Element("Medals"));
                    infos.Add(medal);
                }
            }
            return(infos);
        }
Exemplo n.º 2
0
        public static List <CountryStatisticInfo> Load()
        {
            List <CountryStatisticInfo> data = new List <CountryStatisticInfo>();

            try {
                XDocument Top10LargestCountries_xml = DataLoader.LoadXDocumentFromResources("/Data/CountriesGDPByYears.xml");
                foreach (XElement countryInfo in Top10LargestCountries_xml.Root.Elements("CountryInfo"))
                {
                    string name      = countryInfo.Element("Name").Value;
                    string gdp       = countryInfo.Element("GDP").Value;
                    string continent = countryInfo.Element("Continent").Value;
                    List <GDPStatisticByYear> statistic           = LoadStatistic(countryInfo.Element("Statistic"));
                    CountryStatisticInfo      countryInfoInstance = new CountryStatisticInfo(name, continent, Convert.ToDouble(gdp), statistic);
                    data.Add(countryInfoInstance);
                }
            }
            catch {
            }
            return(data);
        }
Exemplo n.º 3
0
        List <CountryEnergyInfo> LoadDataFromXML()
        {
            XDocument document             = DataLoader.LoadXDocumentFromResources("/Data/EnergyStatistic.xml");
            List <CountryEnergyInfo> infos = new List <CountryEnergyInfo>();

            if (document != null)
            {
                foreach (XElement element in document.Element("ArrayOfEnergyStatistic").Elements())
                {
                    CountryEnergyInfo energyInfo = new CountryEnergyInfo();
                    energyInfo.Country = element.Attribute("Country").Value;
                    foreach (XElement energyElement in element.Elements())
                    {
                        EnergyStatisticItem item = new EnergyStatisticItem();
                        item.TypeName = energyElement.Attribute("TypeName").Value;
                        item.Value    = Convert.ToDouble(energyElement.Attribute("Value").Value, CultureInfo.InvariantCulture);
                        energyInfo.EnergyStatistic.Add(item);
                    }
                    infos.Add(energyInfo);
                }
            }
            return(infos);
        }