public void DuplicateScannerInAlbum() { // for this test, create new 'ituner' playlist and add duplicate entries.. DuplicateScanner scanner = new DuplicateScanner(controller, catalog); scanner.PlaylistFilter = PersistentID.Parse("612F0BCDC4E08C4E"); scanner.Execute(); }
public void ReloadPlaylist() { // 46CD262697DA37D9 == Classical Music PersistentID persistentID = PersistentID.Parse("46CD262697DA37D9"); XElement playlist = null; try { using (Stream stream = File.Open(libraryXMLPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { var settings = new XmlReaderSettings(); settings.IgnoreComments = true; settings.IgnoreProcessingInstructions = true; settings.IgnoreWhitespace = true; settings.DtdProcessing = DtdProcessing.Ignore; using (var reader = XmlReader.Create(stream, settings)) { // read into //plist/dict and stop at the first ./array // this is the playlists collection if (reader.ReadToDescendant("array")) { // by using this subreader and pumping the stream through // XElement.ReadFrom, we should avoid the Large Object Heap using (var subreader = reader.ReadSubtree()) { playlist = XElement.ReadFrom(subreader) as XElement; } } } } } catch (Exception exc) { Debug.WriteLine(exc.Message); return; } if (playlist != null) { XElement target = (from node in playlist .Elements("dict") .Elements("key") where node.Value == "Playlist Persistent ID" && ((XElement)node.NextNode).Value == (string)persistentID select node.Parent).FirstOrDefault(); if (target != null) { var list = from node in target .Elements("array") .Elements("dict") .Elements("integer") select node.Value; } } }