Ejemplo n.º 1
0
        /// <summary>
        /// Removes an audiobook from this library and removes the link to it from the audiobook.
        /// The link is only removed if it points to this library.
        /// </summary>
        /// <param name="audiobook">audiobook to be removed</param>
        public void RemoveAudiobook(Audiobook audiobook)
        {
            if (Contains(audiobook))
            {
                Audiobooks.Remove(audiobook.ID);

                if (audiobook.Library.Equals(this))
                {
                    audiobook.Library = null;
                }
                DeleteMetadataFolder(audiobook.Metadata.MetadataPath);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds an audiobook to the Library. If it is already added the audiobook is updated.
        /// Every audiobook that is new to the library gets a new metadata path.
        /// </summary>
        public void UpdateAudiobook(Audiobook audiobook)
        {
            if (Contains(audiobook))
            {
                ClearChapterMetadata(audiobook);
                Audiobooks.Remove(audiobook.ID);
            }
            else
            {
                audiobook.Metadata.MetadataPath = Path.Combine(MetadataFolder, Guid.NewGuid().ToString());
            }

            AddAudiobook(audiobook);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds an audiobook to this library if it is not already added.
        /// </summary>
        /// <param name="audiobook"></param>
        private void AddAudiobook(Audiobook audiobook)
        {
            if (!(audiobook == null || Contains(audiobook)) && audiobook.Chapters.Count > 0)
            {
                if (audiobook.Library != null)
                {
                    audiobook.Library.RemoveAudiobook(audiobook);
                }
                audiobook.Library = this;

                Audiobooks.Add(audiobook.ID, audiobook);

                SaveMetadata(audiobook);
            }
        }
Ejemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = PlayListID;
         hashCode = (hashCode * 397) ^ Name.GetHashCode();
         hashCode = (hashCode * 397) ^ Master.GetHashCode();
         hashCode = (hashCode * 397) ^ PlayListID.GetHashCode();
         hashCode = (hashCode * 397) ^ PlaylistPersistentID.GetHashCode();
         hashCode = (hashCode * 397) ^ ParentPersistentID.GetHashCode();
         hashCode = (hashCode * 397) ^ Visible.GetHashCode();
         hashCode = (hashCode * 397) ^ AllItems.GetHashCode();
         hashCode = (hashCode * 397) ^ DistinguishedKind.GetHashCode();
         hashCode = (hashCode * 397) ^ Movies.GetHashCode();
         hashCode = (hashCode * 397) ^ TVShows.GetHashCode();
         hashCode = (hashCode * 397) ^ PodCasts.GetHashCode();
         hashCode = (hashCode * 397) ^ iTunesU.GetHashCode();
         hashCode = (hashCode * 397) ^ Audiobooks.GetHashCode();
         hashCode = (hashCode * 397) ^ Books.GetHashCode();
         hashCode = (hashCode * 397) ^ Folder.GetHashCode();
         hashCode = (hashCode * 397) ^ PlaylistItems.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Checks whether this library contains an audiobook with the same id.
 /// </summary>
 /// <param name="id">id which is searched for</param>
 /// <returns>true if an audiobook with the same id is already added to this library</returns>
 public bool Contains(int id)
 {
     return(Audiobooks.ContainsKey(id));
 }