File size: 842 Bytes
18a519f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
        }
    }
}