Year.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. namespace MediaBrowser.Controller.Entities
  6. {
  7. /// <summary>
  8. /// Class Year
  9. /// </summary>
  10. public class Year : BaseItem, IItemByName
  11. {
  12. /// <summary>
  13. /// Gets the user data key.
  14. /// </summary>
  15. /// <returns>System.String.</returns>
  16. protected override string CreateUserDataKey()
  17. {
  18. return "Year-" + Name;
  19. }
  20. /// <summary>
  21. /// Returns the folder containing the item.
  22. /// If the item is a folder, it returns the folder itself
  23. /// </summary>
  24. /// <value>The containing folder path.</value>
  25. public override string ContainingFolderPath
  26. {
  27. get
  28. {
  29. return Path;
  30. }
  31. }
  32. /// <summary>
  33. /// Gets a value indicating whether this instance is owned item.
  34. /// </summary>
  35. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  36. public override bool IsOwnedItem
  37. {
  38. get
  39. {
  40. return false;
  41. }
  42. }
  43. public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
  44. {
  45. int year;
  46. var usCulture = new CultureInfo("en-US");
  47. if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out year))
  48. {
  49. return inputItems;
  50. }
  51. return inputItems.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year);
  52. }
  53. public Func<BaseItem, bool> ItemFilter
  54. {
  55. get { throw new System.NotImplementedException(); }
  56. }
  57. }
  58. }