2
0

MetadataResult.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #nullable disable
  2. #pragma warning disable CA1002, CA2227, CS1591
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using MediaBrowser.Controller.Entities;
  6. using MediaBrowser.Model.Entities;
  7. namespace MediaBrowser.Controller.Providers
  8. {
  9. public class MetadataResult<T>
  10. {
  11. // Images aren't always used so the allocation is a waste a lot of the time
  12. private List<LocalImageInfo> _images;
  13. private List<(string Url, ImageType Type)> _remoteImages;
  14. private List<PersonInfo> _people;
  15. public MetadataResult()
  16. {
  17. ResultLanguage = "en";
  18. }
  19. public List<LocalImageInfo> Images
  20. {
  21. get => _images ??= [];
  22. set => _images = value;
  23. }
  24. public List<(string Url, ImageType Type)> RemoteImages
  25. {
  26. get => _remoteImages ??= [];
  27. set => _remoteImages = value;
  28. }
  29. public IReadOnlyList<PersonInfo> People
  30. {
  31. get => _people;
  32. set => _people = value?.ToList();
  33. }
  34. public bool HasMetadata { get; set; }
  35. public T Item { get; set; }
  36. public string ResultLanguage { get; set; }
  37. public string Provider { get; set; }
  38. public bool QueriedById { get; set; }
  39. public void AddPerson(PersonInfo p)
  40. {
  41. People ??= new List<PersonInfo>();
  42. PeopleHelper.AddPerson(_people, p);
  43. }
  44. /// <summary>
  45. /// Not only does this clear, but initializes the list so that services can differentiate between a null list and zero people.
  46. /// </summary>
  47. public void ResetPeople()
  48. {
  49. if (People is null)
  50. {
  51. People = new List<PersonInfo>();
  52. }
  53. else
  54. {
  55. _people.Clear();
  56. }
  57. }
  58. }
  59. }