Person.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using MediaBrowser.Controller.Providers;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace MediaBrowser.Controller.Entities
  6. {
  7. /// <summary>
  8. /// This is the full Person object that can be retrieved with all of it's data.
  9. /// </summary>
  10. public class Person : BaseItem, IItemByName, IHasLookupInfo<PersonLookupInfo>
  11. {
  12. /// <summary>
  13. /// Gets or sets the place of birth.
  14. /// </summary>
  15. /// <value>The place of birth.</value>
  16. public string PlaceOfBirth { get; set; }
  17. /// <summary>
  18. /// Gets the user data key.
  19. /// </summary>
  20. /// <returns>System.String.</returns>
  21. protected override string CreateUserDataKey()
  22. {
  23. return "Person-" + Name;
  24. }
  25. public PersonLookupInfo GetLookupInfo()
  26. {
  27. return GetItemLookupInfo<PersonLookupInfo>();
  28. }
  29. /// <summary>
  30. /// Returns the folder containing the item.
  31. /// If the item is a folder, it returns the folder itself
  32. /// </summary>
  33. /// <value>The containing folder path.</value>
  34. public override string ContainingFolderPath
  35. {
  36. get
  37. {
  38. return Path;
  39. }
  40. }
  41. /// <summary>
  42. /// Gets a value indicating whether this instance is owned item.
  43. /// </summary>
  44. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  45. public override bool IsOwnedItem
  46. {
  47. get
  48. {
  49. return false;
  50. }
  51. }
  52. public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
  53. {
  54. return inputItems.Where(ItemFilter);
  55. }
  56. public Func<BaseItem, bool> ItemFilter
  57. {
  58. get { return i => i.People.Any(p => string.Equals(p.Name, Name, StringComparison.OrdinalIgnoreCase)); }
  59. }
  60. }
  61. /// <summary>
  62. /// This is the small Person stub that is attached to BaseItems
  63. /// </summary>
  64. public class PersonInfo
  65. {
  66. /// <summary>
  67. /// Gets or sets the name.
  68. /// </summary>
  69. /// <value>The name.</value>
  70. public string Name { get; set; }
  71. /// <summary>
  72. /// Gets or sets the role.
  73. /// </summary>
  74. /// <value>The role.</value>
  75. public string Role { get; set; }
  76. /// <summary>
  77. /// Gets or sets the type.
  78. /// </summary>
  79. /// <value>The type.</value>
  80. public string Type { get; set; }
  81. /// <summary>
  82. /// Gets or sets the sort order - ascending
  83. /// </summary>
  84. /// <value>The sort order.</value>
  85. public int? SortOrder { get; set; }
  86. /// <summary>
  87. /// Returns a <see cref="System.String" /> that represents this instance.
  88. /// </summary>
  89. /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
  90. public override string ToString()
  91. {
  92. return Name;
  93. }
  94. public bool IsType(string type)
  95. {
  96. return string.Equals(Type, type, StringComparison.OrdinalIgnoreCase) || string.Equals(Role, type, StringComparison.OrdinalIgnoreCase);
  97. }
  98. }
  99. }