private LibraryPlaylist ReadPlaylist(XmlDictReader aReader) { LibraryPlaylist playlist = new LibraryPlaylist(); while (!aReader.EndOfDict) { string propKey = aReader.ReadKey(); if (propKey == "Name") { playlist.Name = aReader.ReadValueString(); } else if (propKey == "Playlist ID") { playlist.Id = aReader.ReadValueLong(); } else if (propKey == "Playlist Persistent ID") { playlist.PersistentId = aReader.ReadValueString(); } else if (propKey == "Visible") { playlist.IsVisible = aReader.ReadValueBool(); } else if (propKey == "Distinguished Kind") { playlist.DistinguishedKind = aReader.ReadValueLong(); } else if (propKey == "Smart Info" || propKey == "Smart Criteria") { playlist.IsSmart = true; aReader.SkipValue(); } else if (propKey == "Playlist Items") { XmlArrayReader itemListReader = aReader.ReadValueArrayBegin(); while (!itemListReader.EndOfArray) { XmlDictReader itemReader = itemListReader.ReadValueDictBegin(); itemReader.ReadKey(); playlist.Items.Add(itemReader.ReadValueLong()); itemListReader.ReadValueDictEnd(itemReader); } aReader.ReadValueArrayEnd(itemListReader); } else { aReader.SkipValue(); } } return(playlist); }
public LibraryXmlReaderPlaylists(string aFilename) { iReader = OpenFile(aFilename); try { XmlDictReader rootReader = new XmlDictReader(iReader); ReadToKey(rootReader, "Playlists"); if (!rootReader.EndOfDict) { iPlaylistListReader = rootReader.ReadValueArrayBegin(); } } catch (Exception) { iReader.Close(); throw; } }