private static bool AllArtistsExist(AlbumTO p_Album, IDictionary <string, Artist> p_Artists) { foreach (var artistName in p_Album.Artists) { if (!p_Artists.ContainsKey(artistName)) { return(false); } } return(true); }
public static IDictionary <int, AlbumTO> GetAlbums() { IDictionary <int, AlbumTO> result = new Dictionary <int, AlbumTO>(); var reader = new StreamReader(m_Album_Path); reader.ReadLine(); //skip first header line string line; int count = 1; while ((line = reader.ReadLine()) != null) { var commas = GetCommasInLine(line, m_CommasInLine); if (commas.Count < 2) { Console.WriteLine(string.Format("Incorrect line: Not enough commas in line {0}", count)); continue; } var indexPairs = commas.Count == 2 ? GetPropStartEndIndex(commas, line.Length) : GetPropStartEndIndex(commas); var subStrings = GetCSVSubStrings(indexPairs, line); var album = new AlbumTO(); album.Name = subStrings[0]; album.Year = Convert.ToInt32(subStrings[2]); //Artists var artistLine = subStrings[1]; commas = GetCommasInLine(artistLine); indexPairs = GetPropStartEndIndex(commas, artistLine.Length); subStrings = GetCSVSubStrings(indexPairs, artistLine); foreach (string artist in subStrings) { album.Artists.Add(artist); } result.Add(count, album); count++; } return(result); }