public async Task <LcDayDto> GetData(DateTime date) { var result = new LcDayDto(); if (Data.Days.ContainsKey(date)) { result = Data.Days[date]; } else { try { result = await DownloadDateExact(date); Data.Days.Add(date, result); } catch { return(null); } } return(result); }
public void Load() { //TODO zmenit na povodne if (Application.Current.Properties.ContainsKey("DataStorage")) { var serializedStorage = Application.Current.Properties["DataStorage"] as string; if (string.IsNullOrEmpty(serializedStorage)) { return; } var serializer = new XmlSerializer(typeof(Storer[]), new XmlRootAttribute() { ElementName = "items" }); using (var reader = new StringReader(serializedStorage)) { var ser = new XmlSerializer(typeof(LcDayDto)); Data = new LcKbsDto(); Data.Days = (serializer.Deserialize(reader) as Storer[]).ToDictionary(i => i.Key, i => { var res = new LcDayDto(); using (var readerStorer = new StringReader(i.LcDay)) { res = ser.Deserialize(readerStorer) as LcDayDto; } return(res); }); } } else { Data = new LcKbsDto(); } }