Using new .Chunk and .DistinctBy Linq Extensions

This commit is contained in:
Kwoth
2021-12-24 02:10:21 +01:00
parent 594a3b1f97
commit 26ee6ce4d3
6 changed files with 14 additions and 45 deletions

View File

@@ -39,7 +39,7 @@ public partial class Utility
{
var selection = typeof(Math).GetTypeInfo()
.GetMethods()
.Distinct(new MethodInfoEqualityComparer())
.DistinctBy(x => x.Name)
.Select(x => x.Name)
.Except(new[]
{
@@ -51,11 +51,4 @@ public partial class Utility
await SendConfirmAsync(GetText(strs.calcops(Prefix)), string.Join(", ", selection));
}
}
private class MethodInfoEqualityComparer : IEqualityComparer<MethodInfo>
{
public bool Equals(MethodInfo x, MethodInfo y) => x.Name == y.Name;
public int GetHashCode(MethodInfo obj) => obj.Name.GetHashCode(StringComparison.InvariantCulture);
}
}