private async Task LoadCollection(StorageFolder root) { Dictionary <string, Album> stagingCollection = new Dictionary <string, Album>(); using (var entries = await TSVReader <CollectionEntry> .Load(collectionPath(root))) foreach (CollectionEntry entry in entries) { string key = GetAlbumKey(entry); Album album; if (!stagingCollection.TryGetValue(key, out album)) { album = CreateAlbum(entry); stagingCollection[key] = album; string coverPath; album.CoverPath = covers.TryGetValue(GetAlbumKey(entry), out coverPath) ? Path.Combine(root.Path, coverPath) : null; } album.Tracks.Add(CreateTrack(entry, album)); album.Tracks.Sort((t1, t2) => t1.Number.CompareTo(t2.Number)); } Collection = new List <Album>(stagingCollection.Values); }
private async Task LoadAlbumCovers(StorageFolder root) { using (var entries = await TSVReader <AlbumCoverEntry> .Load(albumCoversPath(root))) foreach (AlbumCoverEntry entry in entries) { covers.Add($"{entry.Composer}|{entry.AlbumArtist}|{entry.Composition}|{entry.Genre}", entry.Filename); } }
public async static Task <TSVReader <TRecord> > Load(string filepath) { var result = new TSVReader <TRecord>(); StorageFile file = await StorageFile.GetFileFromPathAsync(filepath); var stream = new StreamReader(await file.OpenStreamForReadAsync()); result.reader = new CsvReader(stream, config);; result.records = result.reader.GetRecords <TRecord>(); return(result); }