UnityGame/Library/PackageCache/com.unity.visualscripting/Runtime/VisualScripting.Flow/Framework/Control/SelectOnString.cs

31 lines
842 B
C#
Raw Permalink Normal View History

2024-10-27 10:53:47 +03:00
using System;
namespace Unity.VisualScripting
{
/// <summary>
/// Selects a value from a set by switching over a string.
/// </summary>
[UnitCategory("Control")]
[UnitTitle("Select On String")]
[UnitShortTitle("Select")]
[UnitSubtitle("On String")]
[UnitOrder(7)]
public class SelectOnString : SelectUnit<string>
{
[Serialize]
[Inspectable, UnitHeaderInspectable("Ignore Case")]
[InspectorToggleLeft]
public bool ignoreCase { get; set; }
protected override bool Matches(string a, string b)
{
if (string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b))
{
return true;
}
return string.Equals(a, b, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
}
}
}