Person.cs 3.3 KB

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