示例#1
0
        private TagData toTagData()
        {
            TagData result = new TagData();

            result.Title              = Title;
            result.Artist             = Artist;
            result.Composer           = Composer;
            result.Comment            = Comment;
            result.Genre              = Genre;
            result.OriginalArtist     = OriginalArtist;
            result.OriginalAlbum      = OriginalAlbum;
            result.GeneralDescription = Description;
            result.Rating             = (Popularity * 5).ToString();
            result.Copyright          = Copyright;
            result.Publisher          = Publisher;
            if (!PublishingDate.Equals(DateTime.MinValue))
            {
                result.PublishingDate = TrackUtils.FormatISOTimestamp(PublishingDate);
            }
            result.AlbumArtist = AlbumArtist;
            result.Conductor   = Conductor;
            if (!Date.Equals(DateTime.MinValue))
            {
                result.RecordingDate = TrackUtils.FormatISOTimestamp(Date);
            }
            result.RecordingYear            = Year.ToString();
            result.Album                    = Album;
            result.TrackNumber              = TrackNumber.ToString();
            result.TrackTotal               = TrackTotal.ToString();
            result.DiscNumber               = DiscNumber.ToString();
            result.DiscTotal                = DiscTotal.ToString();
            result.ChaptersTableDescription = ChaptersTableDescription.ToString();

            result.Chapters = new List <ChapterInfo>();
            foreach (ChapterInfo chapter in Chapters)
            {
                result.Chapters.Add(new ChapterInfo(chapter));
            }

            if (Lyrics != null)
            {
                result.Lyrics = new LyricsInfo(Lyrics);
            }

            foreach (string s in AdditionalFields.Keys)
            {
                result.AdditionalFields.Add(new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, s, AdditionalFields[s]));
            }

            // Detect and tag deleted Additional fields (=those which were in initialAdditionalFields and do not appear in AdditionalFields anymore)
            foreach (string s in initialAdditionalFields)
            {
                if (!AdditionalFields.ContainsKey(s))
                {
                    MetaFieldInfo metaFieldToDelete = new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, s, "");
                    metaFieldToDelete.MarkedForDeletion = true;
                    result.AdditionalFields.Add(metaFieldToDelete);
                }
            }

            result.Pictures = new List <PictureInfo>();
            if (currentEmbeddedPictures != null)
            {
                foreach (PictureInfo targetPic in currentEmbeddedPictures)
                {
                    targetPic.TransientFlag = 0;
                }
            }

            if (initialEmbeddedPictures != null && currentEmbeddedPictures != null)
            {
                foreach (PictureInfo picInfo in initialEmbeddedPictures)
                {
                    // Detect and tag deleted pictures (=those which were in initialEmbeddedPictures and do not appear in embeddedPictures anymore)
                    if (!currentEmbeddedPictures.Contains(picInfo))
                    {
                        PictureInfo picToDelete = new PictureInfo(picInfo);
                        picToDelete.MarkedForDeletion = true;
                        result.Pictures.Add(picToDelete);
                    }
                    else // Only add new additions (pictures identical to initial list will be kept, and do not have to make it to the list, or else a duplicate will be created)
                    {
                        foreach (PictureInfo targetPic in currentEmbeddedPictures)
                        {
                            if (targetPic.Equals(picInfo))
                            {
                                // Compare picture contents
                                targetPic.ComputePicHash();

                                if (targetPic.PictureHash != picInfo.PictureHash)
                                {
                                    // A new picture content has been defined for an existing location
                                    result.Pictures.Add(targetPic);

                                    PictureInfo picToDelete = new PictureInfo(picInfo);
                                    picToDelete.MarkedForDeletion = true;
                                    result.Pictures.Add(picToDelete);
                                }

                                targetPic.TransientFlag = 1;
                            }
                        }
                    }
                }

                if (currentEmbeddedPictures != null)
                {
                    foreach (PictureInfo targetPic in currentEmbeddedPictures)
                    {
                        if (0 == targetPic.TransientFlag) // Entirely new pictures without equivalent in initialEmbeddedPictures
                        {
                            result.Pictures.Add(targetPic);
                        }
                    }
                }
            }

            return(result);
        }
示例#2
0
 public string GetAllProperties()
 {
     return(Isbn + ";" + Title + ";" + Author + ";" + PublishingDate.ToString("MMMM dd, yyyy") + ";" + GrossPrice + ";" + Vat);
 }