diff --git a/src/ICU4N/Support/AnonymousComparer.cs b/src/ICU4N/Support/AnonymousComparer.cs deleted file mode 100644 index 810bb9d2..00000000 --- a/src/ICU4N/Support/AnonymousComparer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace ICU4N.Support -{ - internal class AnonymousComparer : IComparer - { - private readonly Func compare; - - public AnonymousComparer(Func compare) - { - this.compare = compare ?? throw new ArgumentNullException(nameof(compare)); - } - - public int Compare(T x, T y) - { - return compare(x, y); - } - } -} diff --git a/tests/ICU4N.Tests/Dev/Test/Util/ICUServiceTest.cs b/tests/ICU4N.Tests/Dev/Test/Util/ICUServiceTest.cs index cf7934a0..d2e0bd28 100644 --- a/tests/ICU4N.Tests/Dev/Test/Util/ICUServiceTest.cs +++ b/tests/ICU4N.Tests/Dev/Test/Util/ICUServiceTest.cs @@ -474,7 +474,7 @@ public void TestAPI() // list the display names in reverse order { Logln("display names in reverse order: " + - service.GetDisplayNames(new UCultureInfo("en_US"), new AnonymousComparer(compare: (lhs, rhs) => + service.GetDisplayNames(new UCultureInfo("en_US"), Comparer.Create(comparison: (lhs, rhs) => { return -StringComparer.OrdinalIgnoreCase.Compare((string)lhs, (string)rhs); }))); @@ -888,7 +888,7 @@ public void TestLocale() // hmmm, the default toString function doesn't print in sorted order for TreeMap { var map = service.GetDisplayNames(new UCultureInfo("en_US"), - new AnonymousComparer(compare: (lhs, rhs) => + Comparer.Create(comparison: (lhs, rhs) => { return -StringComparer.OrdinalIgnoreCase.Compare((string)lhs, (string)rhs); }), diff --git a/tests/ICU4N.Tests/Dev/Test/Util/ICUServiceThreadTest.cs b/tests/ICU4N.Tests/Dev/Test/Util/ICUServiceThreadTest.cs index fa1b521a..5c03242b 100644 --- a/tests/ICU4N.Tests/Dev/Test/Util/ICUServiceThreadTest.cs +++ b/tests/ICU4N.Tests/Dev/Test/Util/ICUServiceThreadTest.cs @@ -505,7 +505,7 @@ public void Test04_WitheringService() RegisterFactories(service, fc); IServiceFactory[] factories = (IServiceFactory[])fc.ToArray(); - var comp = new AnonymousComparer(compare: (lhs, rhs) => + var comp = Comparer.Create(comparison: (lhs, rhs) => { return lhs.ToString().CompareToOrdinal(rhs.ToString()); });