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 LibraryHeader Read(string aFilename) { LibraryHeader header = new LibraryHeader(); XmlReader reader = OpenFile(aFilename); try { XmlDictReader dictReader = new XmlDictReader(reader); while (!dictReader.EndOfDict) { string key = dictReader.ReadKey(); if (key == "Major Version") { header.MajorVersion = dictReader.ReadValueLong(); } else if (key == "Minor Version") { header.MinorVersion = dictReader.ReadValueLong(); } else if (key == "Application Version") { header.AppVersion = dictReader.ReadValueString(); } else if (key == "Features") { header.Features = dictReader.ReadValueLong(); } else if (key == "Show Content Ratings") { header.ShowContentRatings = dictReader.ReadValueBool(); } else if (key == "Music Folder") { header.MusicFolder = dictReader.ReadValueString(); } else if (key == "Library Persistent ID") { header.LibraryId = dictReader.ReadValueString(); } else { dictReader.SkipValue(); } } } finally { reader.Close(); } return(header); }