Person.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. public override string GetUserDataKey()
  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(i => i.People.Any(p => string.Equals(p.Name, Name, StringComparison.OrdinalIgnoreCase)));
  55. }
  56. }
  57. /// <summary>
  58. /// This is the small Person stub that is attached to BaseItems
  59. /// </summary>
  60. public class PersonInfo
  61. {
  62. /// <summary>
  63. /// Gets or sets the name.
  64. /// </summary>
  65. /// <value>The name.</value>
  66. public string Name { get; set; }
  67. /// <summary>
  68. /// Gets or sets the role.
  69. /// </summary>
  70. /// <value>The role.</value>
  71. public string Role { get; set; }
  72. /// <summary>
  73. /// Gets or sets the type.
  74. /// </summary>
  75. /// <value>The type.</value>
  76. public string Type { get; set; }
  77. /// <summary>
  78. /// Gets or sets the sort order - ascending
  79. /// </summary>
  80. /// <value>The sort order.</value>
  81. public int? SortOrder { get; set; }
  82. /// <summary>
  83. /// Returns a <see cref="System.String" /> that represents this instance.
  84. /// </summary>
  85. /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
  86. public override string ToString()
  87. {
  88. return Name;
  89. }
  90. }
  91. }