暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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. }