コード例 #1
0
        public static SongsCollection GetSongsByName(string name)
        {
            var result = new SongsCollection();

            songs.Where(s => s.Name == name).ToList().ForEach(result.Add);
            return(result);
        }
コード例 #2
0
ファイル: Album.cs プロジェクト: Deryalen/MusicCatalogue
        public Album(string name, DateTime publishmentDate, SongsCollection songs)
        {
            this.Name            = name;
            this.PublishmentDate = publishmentDate;
            this.Songs           = songs;

            this.CreateTimeStamp = DateTime.Now;
            this.UpdateTimeStamp = DateTime.Now;
        }
コード例 #3
0
        /// <summary>
        ///     Fills the collection with songs.
        /// </summary>
        /// <param name="files">array of song paths.</param>
        public static void FillCollectionWithSongs(List <string> files)
        {
            MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            foreach (var songPath in files)
            {
                SongsCollection.AddItem(songPath);
            }
        }
コード例 #4
0
        public Artist(string name, DateTime year, SongsCollection songs, AlbumsCollection albums)
        {
            this.Name   = name;
            this.Year   = year;
            this.Songs  = songs;
            this.Albums = albums;

            this.CreateTimeStamp = DateTime.Now;
            this.UpdateTimeStamp = DateTime.Now;
        }
コード例 #5
0
        /// <summary>
        ///     Fills the collection with songs. Add all of the songs found in the
        ///     users music collection to SongsCollection class.
        /// </summary>
        /// <returns>
        ///     <c>true</c>, if collection with songs was filled, <c>false</c> otherwise.
        /// </returns>
        /// <param name="songPaths">Song paths.</param>
        private bool FillCollectionWithSongs(string[] songPaths)
        {
            var retVal           = false;
            var songPathNotFound = string.Empty;

            try
            {
                MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name;

                foreach (var songPath in songPaths)
                {
                    songPathNotFound = songPath;
                    var compMp3 = -1;
                    var fifo    = new FileInfo(songPath);

                    compMp3 = string.Compare(fifo.Extension, ".mp3", StringComparison.OrdinalIgnoreCase);

                    // If .mp3 music file add it to the collection.
                    if (compMp3 == 0)
                    {
                        if (!File.Exists(songPath))
                        {
                            MyMessages.ErrorMessage = "Invalid file path. This will not be added to the collection.";
                            MyMessages.ErrorMessage = string.Concat(MyMessages.ErrorMessage, Environment.NewLine);
                            MyMessages.ErrorMessage = string.Concat(MyMessages.ErrorMessage, songPath);
                            MyMessages.ShowErrorMessage(MyMessages.ErrorMessage, MyMessages.NameOfClass);
                        }

                        if (loadAllSongs)
                        {
                            SongsCollection.AddItem(songPath);
                        }
                    }
                    else if (loadGenreWorkingDirectory)
                    {
                        SongsCollection.AddItem(songPath);
                        SongsCollection.AddItem(songPath);
                    }
                }

                // All OK
                retVal = true;
                return(retVal);
            }
            catch (UnauthorizedAccessException ex)
            {
                MyMessages.ErrorMessage = "You do not have authorization to access this directory.";
                MyMessages.ErrorMessage = string.Concat(MyMessages.ErrorMessage, Environment.NewLine);
                MyMessages.ErrorMessage = string.Concat(MyMessages.ErrorMessage, songPathNotFound);
                MyMessages.BuildErrorString(MyMessages.NameOfClass, MyMessages.NameOfMethod, MyMessages.ErrorMessage,
                                            ex.Message);
                return(retVal);
            }
        }