Genre.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Runtime.Serialization;
  2. using MediaBrowser.Controller.Entities.Audio;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. namespace MediaBrowser.Controller.Entities
  7. {
  8. /// <summary>
  9. /// Class Genre
  10. /// </summary>
  11. public class Genre : BaseItem, IItemByName
  12. {
  13. /// <summary>
  14. /// Gets the user data key.
  15. /// </summary>
  16. /// <returns>System.String.</returns>
  17. protected override string CreateUserDataKey()
  18. {
  19. return "Genre-" + Name;
  20. }
  21. /// <summary>
  22. /// Returns the folder containing the item.
  23. /// If the item is a folder, it returns the folder itself
  24. /// </summary>
  25. /// <value>The containing folder path.</value>
  26. [IgnoreDataMember]
  27. public override string ContainingFolderPath
  28. {
  29. get
  30. {
  31. return Path;
  32. }
  33. }
  34. public override bool CanDelete()
  35. {
  36. return false;
  37. }
  38. /// <summary>
  39. /// Gets a value indicating whether this instance is owned item.
  40. /// </summary>
  41. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  42. [IgnoreDataMember]
  43. public override bool IsOwnedItem
  44. {
  45. get
  46. {
  47. return false;
  48. }
  49. }
  50. public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
  51. {
  52. return inputItems.Where(GetItemFilter());
  53. }
  54. public Func<BaseItem, bool> GetItemFilter()
  55. {
  56. return i => !(i is Game) && !(i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase);
  57. }
  58. }
  59. }