MusicAlbum.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System.Linq;
  2. using System.Runtime.Serialization;
  3. namespace MediaBrowser.Controller.Entities.Audio
  4. {
  5. /// <summary>
  6. /// Class MusicAlbum
  7. /// </summary>
  8. public class MusicAlbum : Folder
  9. {
  10. /// <summary>
  11. /// Songs will group into us so don't also include us in the index
  12. /// </summary>
  13. /// <value><c>true</c> if [include in index]; otherwise, <c>false</c>.</value>
  14. [IgnoreDataMember]
  15. public override bool IncludeInIndex
  16. {
  17. get
  18. {
  19. return false;
  20. }
  21. }
  22. /// <summary>
  23. /// Override this to true if class should be grouped under a container in indicies
  24. /// The container class should be defined via IndexContainer
  25. /// </summary>
  26. /// <value><c>true</c> if [group in index]; otherwise, <c>false</c>.</value>
  27. [IgnoreDataMember]
  28. public override bool GroupInIndex
  29. {
  30. get
  31. {
  32. return true;
  33. }
  34. }
  35. /// <summary>
  36. /// The unknwon artist
  37. /// </summary>
  38. private static readonly MusicArtist UnknwonArtist = new MusicArtist { Name = "<Unknown>" };
  39. /// <summary>
  40. /// Override this to return the folder that should be used to construct a container
  41. /// for this item in an index. GroupInIndex should be true as well.
  42. /// </summary>
  43. /// <value>The index container.</value>
  44. [IgnoreDataMember]
  45. public override Folder IndexContainer
  46. {
  47. get { return Parent as MusicArtist ?? UnknwonArtist; }
  48. }
  49. /// <summary>
  50. /// Determines whether the specified artist has artist.
  51. /// </summary>
  52. /// <param name="artist">The artist.</param>
  53. /// <returns><c>true</c> if the specified artist has artist; otherwise, <c>false</c>.</returns>
  54. public bool HasArtist(string artist)
  55. {
  56. return RecursiveChildren.OfType<Audio>().Any(i => i.HasArtist(artist));
  57. }
  58. }
  59. public class MusicAlbumDisc : Folder
  60. {
  61. }
  62. }