public void SetSoundBoards(IEnumerable <Model.SoundBoard> soundBoards) { try { SoundBoardData dataObject = new SoundBoardData { SoundBoards = (from soundBoard in soundBoards select new XmlSoundBoard(soundBoard)).ToArray() }; XmlSerializer serializer = new XmlSerializer(typeof(SoundBoardData)); using (TextWriter textWriter = new StreamWriter(XmlFile)) { serializer.Serialize(textWriter, dataObject); } } catch { return; } }
public IEnumerable <Model.SoundBoard> GetSoundBoards() { try { XmlSerializer serializer = new XmlSerializer(typeof(SoundBoardData)); using (TextReader reader = new StreamReader(XmlFile)) { SoundBoardData soundBoardData = serializer.Deserialize(reader) as SoundBoardData; if (soundBoardData == null) { return(Enumerable.Empty <Model.SoundBoard>()); } return(from xmlBoard in soundBoardData.SoundBoards select xmlBoard.ToSoundBoard(_soundFactory)); } } catch (Exception) { return(Enumerable.Empty <Model.SoundBoard>()); } }