예제 #1
0
        public static CharComparer Create([NotNull] System.StringComparer stringComparer)
        {
            if (stringComparer == null)
            {
                throw new ArgumentNullException(nameof(stringComparer));
            }

            // Handle common equivalents.
            if (stringComparer.Equals(System.StringComparer.InvariantCulture))
            {
                return(InvariantCulture);
            }
            if (stringComparer.Equals(System.StringComparer.InvariantCultureIgnoreCase))
            {
                return(InvariantCultureIgnoreCase);
            }
            if (stringComparer.Equals(System.StringComparer.Ordinal))
            {
                return(Ordinal);
            }
            if (stringComparer.Equals(System.StringComparer.OrdinalIgnoreCase))
            {
                return(OrdinalIgnoreCase);
            }

            // Build a comparer based on the string comparer.
            return(new StringComparer(stringComparer));
        }
예제 #2
0
 /// <inheritdoc />
 public override bool Equals(char x, char y) => _stringComparer.Equals(x.ToString(), y.ToString());
예제 #3
0
 internal static bool EqualsIgnoringCase(this string value1, string value2) => DefaultComparer.Equals(value1, value2);