public Collection(string name, Genre genre, int year, SongList list)
     :   base(list)
 {
     this.name    = name;
     this.genre   = genre;
     this.year    = year;
     this.artists = new List <Artist>();
 }
Пример #2
0
        public virtual ICollection FindByGenre(Genre genre)
        {
            SongList result = new SongList();

            foreach (var song in songs)
            {
                if (song.song_genre.IsSubGenre(genre))
                {
                    result.songs.Add(song);
                }
            }

            return(result);
        }
Пример #3
0
        public virtual ICollection FindBySongName(string name)
        {
            SongList result = new SongList();

            foreach (var song in songs)
            {
                if (song.song_name.Contains(name))
                {
                    result.songs.Add(song);
                }
            }

            return(result);
        }
        private void AddSongByGenre(Song song)
        {
            SongList tmp;

            songs_by_genre.TryGetValue(song.song_genre, out tmp);
            if (object.ReferenceEquals(tmp, null))
            {
                tmp = new SongList();
                tmp.AddSong(song);
                songs_by_genre.Add(song.song_genre, tmp);
            }
            else
            {
                tmp.AddSong(song);
            }
        }
        private void AddSongByYear(Song song)
        {
            SongList tmp = new SongList();

            songs_by_year.TryGetValue(song.song_year, out tmp);
            if (object.ReferenceEquals(tmp, null))
            {
                tmp = new SongList();
                tmp.AddSong(song);
                songs_by_year.Add(song.song_year, tmp);
            }
            else
            {
                tmp.AddSong(song);
            }
        }
Пример #6
0
        public virtual ICollection FindByArtist(string name)
        {
            SongList result = new SongList();

            foreach (var song in songs)
            {
                foreach (var artist in song.song_artists)
                {
                    if (artist.artist_name.Contains(name))
                    {
                        result.songs.Add(song);
                    }
                }
            }

            return(result);
        }
Пример #7
0
        public virtual ICollection FindByYear(int year)
        {
            SongList result = new SongList();

            foreach (var song in songs)
            {
                if (song.song_year == year)
                {
                    result.songs.Add(song);
                }
            }

            if (result.ToList().Count < 1)
            {
                return(null);
            }

            return(result);
        }
Пример #8
0
        public static void FindBySongName(Catalog catalog, SearchQuery query)
        {
            if (query.song == null)
            {
                return;
            }

            List <ICollection> collections = new List <ICollection>();

            if (query.result == null)
            {
                var song_names = catalog.songs_by_name.Keys.Where(x => x.Contains(query.song));

                foreach (var song_name in song_names)
                {
                    catalog.songs_by_name.TryGetValue(song_name, out SongList list);
                    SongList col = (SongList)list.FindBySongName(query.song);
                    if (col != null && col.ToList().Count > 0)
                    {
                        collections.Add(col);
                    }
                }
            }
            else
            {
                foreach (var collection in query.result)
                {
                    ICollection tmp = collection.FindBySongName(query.song);
                    if (tmp != null && tmp.ToList().Count > 0)
                    {
                        collections.Add(tmp);
                    }
                }
            }

            query.result = collections;
            if (query.result.Count == 0)
            {
                query.result = null;
            }
        }
Пример #9
0
 public SongList(SongList other)
 {
     this.songs = other.songs;
 }
        public static Collection MakeCollection(Catalog catalog, string name, Genre genre, int year, SongList list)
        {
            Collection collection = new Collection(name, genre, year, list);

            catalog.AddCollection(collection);
            return(collection);
        }