Esempio n. 1
0
        void GetCollection()
        {
            var dataList = XDocument.Parse(xmlFile).
                           Descendants("weather").
                           Descendants("city").
                           Descendants("step").ToList <XElement>();

            foreach (var item in dataList)
            {
                DayModel temp = new DayModel();
                DayModel.PreparingElement(ref temp, item);
                DataSource.Add(temp);
            }
        }
Esempio n. 2
0
 public static void PreparingElement(ref DayModel current, XElement TempElement)
 {
     current = new DayModel()
     {
         cloudcover =
             $@"http://www.eurometeo.ru/i/ic/7/" +
             $"{(Convert.ToInt32(TempElement.Element("cloudcover").Value.ToString()) % 28) / 3}.png",
         winddir =
             String.Format("http://www.eurometeo.ru/i/a16/{0}.png",
                           Convert.ToInt32(TempElement.Element("winddir").Value.ToString()) / 11),
         datetime = TempElement.Element("datetime").Value.ToString().
                    Replace("04:00:00", "Утро").
                    Replace("10:00:00", "День").
                    Replace("16:00:00", "Вечер").
                    Replace("22:00:00", "Ночь"),
         humidity      = TempElement.Element("humidity").Value.ToString(),
         precipitation = TempElement.Element("precipitation").Value.ToString(),
         pressure      = String.Format("{0} мм.рт.ст.", TempElement.Element("pressure").Value.ToString()),
         temperature   = $"{TempElement.Element("temperature").Value.ToString()} ℃",
         windgust      = TempElement.Element("windgust").Value.ToString(),
         windspeed     = $"{TempElement.Element("windspeed").Value.ToString()} м/с",
         winddir2      = Convert.ToInt32(TempElement.Element("winddir").Value.ToString()),
     };
 }