LinkedChild.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System;
  4. using System.Globalization;
  5. using System.Text.Json.Serialization;
  6. namespace MediaBrowser.Controller.Entities
  7. {
  8. public class LinkedChild
  9. {
  10. public LinkedChild()
  11. {
  12. Id = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
  13. }
  14. public string Path { get; set; }
  15. public LinkedChildType Type { get; set; }
  16. public string LibraryItemId { get; set; }
  17. [JsonIgnore]
  18. public string Id { get; set; }
  19. /// <summary>
  20. /// Gets or sets the linked item id.
  21. /// </summary>
  22. public Guid? ItemId { get; set; }
  23. public static LinkedChild Create(BaseItem item)
  24. {
  25. var child = new LinkedChild
  26. {
  27. Path = item.Path,
  28. Type = LinkedChildType.Manual
  29. };
  30. if (string.IsNullOrEmpty(child.Path))
  31. {
  32. child.LibraryItemId = item.Id.ToString("N", CultureInfo.InvariantCulture);
  33. }
  34. return child;
  35. }
  36. }
  37. }