2
0

LinkedChild.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.Serialization;
  4. namespace MediaBrowser.Controller.Entities
  5. {
  6. public class LinkedChild
  7. {
  8. public string Path { get; set; }
  9. public LinkedChildType Type { get; set; }
  10. public string ItemName { get; set; }
  11. public string ItemType { get; set; }
  12. public int? ItemYear { get; set; }
  13. [IgnoreDataMember]
  14. public string Id { get; set; }
  15. /// <summary>
  16. /// Serves as a cache
  17. /// </summary>
  18. public Guid? ItemId { get; set; }
  19. public static LinkedChild Create(BaseItem item)
  20. {
  21. return new LinkedChild
  22. {
  23. Path = item.Path,
  24. Type = LinkedChildType.Manual
  25. };
  26. }
  27. public LinkedChild()
  28. {
  29. Id = Guid.NewGuid().ToString("N");
  30. }
  31. }
  32. public enum LinkedChildType
  33. {
  34. Manual = 0,
  35. Shortcut = 1
  36. }
  37. public class LinkedChildComparer : IEqualityComparer<LinkedChild>
  38. {
  39. public bool Equals(LinkedChild x, LinkedChild y)
  40. {
  41. if (x.Type == y.Type)
  42. {
  43. return string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase);
  44. }
  45. return false;
  46. }
  47. public int GetHashCode(LinkedChild obj)
  48. {
  49. return (obj.Path + obj.Type).GetHashCode();
  50. }
  51. }
  52. }