MusicAlbum.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Runtime.Serialization;
  4. namespace MediaBrowser.Controller.Entities.Audio
  5. {
  6. /// <summary>
  7. /// Class MusicAlbum
  8. /// </summary>
  9. public class MusicAlbum : Folder
  10. {
  11. /// <summary>
  12. /// Songs will group into us so don't also include us in the index
  13. /// </summary>
  14. /// <value><c>true</c> if [include in index]; otherwise, <c>false</c>.</value>
  15. [IgnoreDataMember]
  16. public override bool IncludeInIndex
  17. {
  18. get
  19. {
  20. return false;
  21. }
  22. }
  23. /// <summary>
  24. /// Override this to true if class should be grouped under a container in indicies
  25. /// The container class should be defined via IndexContainer
  26. /// </summary>
  27. /// <value><c>true</c> if [group in index]; otherwise, <c>false</c>.</value>
  28. [IgnoreDataMember]
  29. public override bool GroupInIndex
  30. {
  31. get
  32. {
  33. return true;
  34. }
  35. }
  36. /// <summary>
  37. /// The unknwon artist
  38. /// </summary>
  39. private static readonly MusicArtist UnknwonArtist = new MusicArtist {Name = "<Unknown>"};
  40. /// <summary>
  41. /// Override this to return the folder that should be used to construct a container
  42. /// for this item in an index. GroupInIndex should be true as well.
  43. /// </summary>
  44. /// <value>The index container.</value>
  45. [IgnoreDataMember]
  46. public override Folder IndexContainer
  47. {
  48. get { return Parent as MusicArtist ?? UnknwonArtist; }
  49. }
  50. /// <summary>
  51. /// Override to point to first child (song) if not explicitly defined
  52. /// </summary>
  53. /// <value>The primary image path.</value>
  54. [IgnoreDataMember]
  55. public override string PrimaryImagePath
  56. {
  57. get
  58. {
  59. if (base.PrimaryImagePath == null)
  60. {
  61. var child = Children.FirstOrDefault();
  62. return child == null ? base.PrimaryImagePath : child.PrimaryImagePath;
  63. }
  64. return base.PrimaryImagePath;
  65. }
  66. set
  67. {
  68. base.PrimaryImagePath = value;
  69. }
  70. }
  71. /// <summary>
  72. /// Override to point to first child (song)
  73. /// </summary>
  74. /// <value>The production year.</value>
  75. public override int? ProductionYear
  76. {
  77. get
  78. {
  79. var child = Children.FirstOrDefault();
  80. return child == null ? base.ProductionYear : child.ProductionYear;
  81. }
  82. set
  83. {
  84. base.ProductionYear = value;
  85. }
  86. }
  87. /// <summary>
  88. /// Override to point to first child (song)
  89. /// </summary>
  90. /// <value>The genres.</value>
  91. public override List<string> Genres
  92. {
  93. get
  94. {
  95. var child = Children.FirstOrDefault();
  96. return child == null ? base.Genres : child.Genres;
  97. }
  98. set
  99. {
  100. base.Genres = value;
  101. }
  102. }
  103. /// <summary>
  104. /// Override to point to first child (song)
  105. /// </summary>
  106. /// <value>The studios.</value>
  107. public override List<string> Studios
  108. {
  109. get
  110. {
  111. var child = Children.FirstOrDefault();
  112. return child == null ? base.Studios : child.Studios;
  113. }
  114. set
  115. {
  116. base.Studios = value;
  117. }
  118. }
  119. }
  120. }