コード例 #1
0
        /// <summary>
        /// This creates a new empty playlist with the given name.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public IPlaylist CreatePlaylist(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException();
            }

            var dbList = new BmpPlaylist()
            {
                Songs = new List <BmpSong>(),
                Name  = name,
                Id    = null
            };

            return(new BmpPlaylistDecorator(dbList));
        }
コード例 #2
0
        /// <summary>
        /// This creates a playlist containing songs that match the given tag.
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        public IPlaylist CreatePlaylistFromTag(string tag)
        {
            if (tag == null)
            {
                throw new ArgumentNullException();
            }

            var songCol = this.GetSongCollection();

            // TODO: This is brute force and not memory efficient; there has to be a better
            // way to do this, but my knowledge of LINQ and BsonExpressions isn't there yet.
            var allSongs = songCol.FindAll();
            var songList = new List <BmpSong>();

            foreach (var entry in allSongs)
            {
                if (TagMatches(tag, entry))
                {
                    songList.Add(entry);
                }
            }

            if (songList.Count == 0)
            {
                return(null);
            }

            var dbList = new BmpPlaylist()
            {
                Name  = tag,
                Songs = songList,
                Id    = null
            };

            return(new BmpPlaylistDecorator(dbList));
        }
コード例 #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="target"></param>
 internal BmpPlaylistDecorator(BmpPlaylist target) => this.target = target ?? throw new NullReferenceException();