You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB

  1. namespace UnityEditor.PackageManager.UI
  2. {
  3. internal class VersionItem
  4. {
  5. internal PackageInfo Version;
  6. public string MenuName { get; set; }
  7. // Base label
  8. public string Label
  9. {
  10. get
  11. {
  12. if (Version == null)
  13. return MenuName;
  14. var label = Version.VersionWithoutTag;
  15. return label;
  16. }
  17. }
  18. public string DropdownLabel
  19. {
  20. get
  21. {
  22. if (Version == null)
  23. return MenuName;
  24. var label = MenuName + Label;
  25. if (Version.IsLocal)
  26. label += " - local";
  27. if (Version.IsCurrent)
  28. label += " - current";
  29. if (Version.IsVerified)
  30. label += " - verified";
  31. else if (!string.IsNullOrEmpty(Version.Version.Prerelease))
  32. label += string.Format(" - {0}", Version.Version.Prerelease);
  33. else if (Version.IsPreview)
  34. label += " - preview";
  35. return label;
  36. }
  37. }
  38. public override string ToString()
  39. {
  40. return DropdownLabel;
  41. }
  42. public override bool Equals(object obj)
  43. {
  44. if (ReferenceEquals(obj, null)) return false;
  45. if (ReferenceEquals(this, obj)) return true;
  46. var other = (VersionItem)obj;
  47. return Version == other.Version;
  48. }
  49. public override int GetHashCode()
  50. {
  51. return Version.GetHashCode();
  52. }
  53. }
  54. }