// Static method to load data public static RadioConfiguration LoadStationsFromXml() { string filepath = "Data\\radiostations.xml"; #if DEBUG filepath = "..\\..\\Data\\radiostations.xml"; #endif if (File.Exists(filepath)) { var filestream = new FileStream(filepath, FileMode.Open, FileAccess.Read); RadioConfiguration stations = null; try { var deserializer = new XmlSerializer(typeof(RadioConfiguration)); stations = (RadioConfiguration)deserializer.Deserialize(filestream); } finally { filestream.Close(); } return(stations); } return(null); }
private void InitializeRadioStation() { radioConf = new RadioConfiguration(); radioStation = new RadioStation(); radioConf = RadioConfiguration.LoadStationsFromXml(); radioConf.CheckNull("Stations"); foreach (var station in radioConf.Stations) { radioStationListBox.Items.Add(station); } }
private void InitializeRadio() { RadioConf = new RadioConfiguration(); //RadioConf.FillWithSampleData(); //RadioConf.SaveToXml(); RadioConf = RadioConfiguration.LoadStationsFromXml(); RadioConf.CheckNull("Stations"); foreach (var station in RadioConf.Stations) { listBoxRadio.Items.Add(station); } }