Пример #1
0
 public SongList(SongListType type)
 {
     Type = type;
 }
Пример #2
0
        public List <SongList> GetSongList(SongListType type)
        {
            switch (type)
            {
            case SongListType.ARTIST:
                List <SongList> artists = new List <SongList>();
                foreach (Song song in Songs)
                {
                    string artistStr = song.Artist;
                    bool   found     = false;
                    foreach (SongList list in artists)
                    {
                        if (list.Data["name"].Equals(artistStr))
                        {
                            list.Songs.Add(song);
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        continue;
                    }
                    else
                    {
                        SongList artist = new SongList(SongListType.ARTIST);
                        artist.Songs.Add(song);
                        artist.Data["name"] = artistStr;
                        artists.Add(artist);
                    }
                }
                return(artists.OrderBy(o => o.Data["name"]).ToList());

            case SongListType.ALBUM:
                List <SongList> albums = new List <SongList>();
                foreach (Song song in Songs)
                {
                    string albumStr = song.Album;
                    bool   found    = false;
                    foreach (SongList list in albums)
                    {
                        if (list.Data["name"].Equals(albumStr) && list.Data["artist"].Equals(song.AlbumArtist))
                        {
                            list.Songs.Add(song);
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        continue;
                    }
                    else
                    {
                        SongList album = new SongList(SongListType.ALBUM);
                        album.Songs.Add(song);
                        album.Data["name"]   = albumStr;
                        album.Data["artist"] = song.AlbumArtist;
                        albums.Add(album);
                    }
                }
                return(albums);

            default:
                return(null);
            }
        }