Esempio n. 1
0
        public static void ImportStars()
        {
            var json  = File.ReadAllText("../../../datasets/stars.json");
            var stars = JsonConvert.DeserializeObject <IEnumerable <StarDto> >(json);

            StarStore.AddStars(stars);
        }
Esempio n. 2
0
        public static void ImportStars()
        {
            var xmlDoc = XDocument.Load("../../datasets/stars.xml");
            var stars  = xmlDoc.Root.Elements();

            StarStore.AddStars(stars);
        }
Esempio n. 3
0
        public static void ImportStars()
        {
            var xml   = XDocument.Load("../../../datasets/stars.xml");
            var stars = xml.Root.Elements().Select(s => new StarImportDto
            {
                Name        = s.Element("Name").Value,
                Temperature = int.Parse(s.Element("Temperature").Value),
                StarSystem  = s.Element("StarSystem").Value
            }).ToList();

            StarStore.AddStars(stars);
        }
Esempio n. 4
0
        public static void ImportStars()
        {
            XDocument starsXml = XDocument.Load(starsDataPath);
            var       stars    = starsXml.Root.Elements()
                                 .Select(e => new StarDto()
            {
                Name        = e.Element("Name").Value,
                Temperature = int.Parse(e.Element("Temperature").Value),
                StarSystem  = e.Element("StarSystem").Value
            });

            StarStore.AddStars(stars);
        }
Esempio n. 5
0
        public static void ImportStars()
        {
            XDocument xmlDoc = LoadXmlFile("stars");
            var       stars  = xmlDoc.Root.Elements();

            List <StarDto> starsDto = new List <StarDto>();

            foreach (XElement star in stars)
            {
                var starDto = new StarDto()
                {
                    Name        = star.Element("Name")?.Value,
                    Temperature = star.Element("Temperature")?.Value,
                    StarSystem  = star.Element("StarSystem")?.Value
                };
                starsDto.Add(starDto);
            }

            StarStore.AddStars(starsDto);
        }