AsteriskStringComparer.cs 951 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections.Generic;
  2. namespace Best.HTTP.Hosts.Settings
  3. {
  4. /// <summary>
  5. /// Moves any added asterisk(*) to the end of the list.
  6. /// </summary>
  7. [Best.HTTP.Shared.PlatformSupport.IL2CPP.Il2CppEagerStaticClassConstruction]
  8. internal sealed class AsteriskStringComparer : IComparer<string>
  9. {
  10. public static readonly AsteriskStringComparer Instance = new AsteriskStringComparer();
  11. public int Compare(string x, string y)
  12. /*{
  13. var comparedTo = x.CompareTo(y);
  14. // Equal?
  15. if (comparedTo == 0)
  16. return 0;
  17. return (x, y) switch
  18. {
  19. ("*", _) => 1,
  20. (_, "*") => -1,
  21. _ => x.CompareTo(y)
  22. };
  23. }*/
  24. => (x, y) switch
  25. {
  26. ("*", "*") => 0,
  27. ("*", _) => 1,
  28. (_, "*") => -1,
  29. _ => x.CompareTo(y)
  30. };
  31. }
  32. }