MetadataResult.cs 1.7 KB

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