暫無描述
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.

SwitchOnString.cs 829B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. namespace Unity.VisualScripting
  3. {
  4. /// <summary>
  5. /// Branches flow by switching over a string.
  6. /// </summary>
  7. [UnitCategory("Control")]
  8. [UnitTitle("Switch On String")]
  9. [UnitShortTitle("Switch")]
  10. [UnitSubtitle("On String")]
  11. [UnitOrder(4)]
  12. public class SwitchOnString : SwitchUnit<string>
  13. {
  14. [Serialize]
  15. [Inspectable, UnitHeaderInspectable("Ignore Case")]
  16. [InspectorToggleLeft]
  17. public bool ignoreCase { get; set; }
  18. protected override bool Matches(string a, string b)
  19. {
  20. if (string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b))
  21. {
  22. return true;
  23. }
  24. return string.Equals(a, b, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
  25. }
  26. }
  27. }