From 1df78345c517baf8f89934dde44154312e5ff1c3 Mon Sep 17 00:00:00 2001 From: Lightczx <1686188646@qq.com> Date: Wed, 7 Feb 2024 09:12:02 +0800 Subject: [PATCH] fix AdvancedCollectionView compare --- .../AdvancedCollectionView/AdvancedCollectionView.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Collection/AdvancedCollectionView/AdvancedCollectionView.cs b/src/Snap.Hutao/Snap.Hutao/Control/Collection/AdvancedCollectionView/AdvancedCollectionView.cs index d85c64e5..a2ab6b2c 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Collection/AdvancedCollectionView/AdvancedCollectionView.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Collection/AdvancedCollectionView/AdvancedCollectionView.cs @@ -16,7 +16,7 @@ using NotifyCollectionChangedAction = System.Collections.Specialized.NotifyColle namespace Snap.Hutao.Control.Collection.AdvancedCollectionView; -internal sealed class AdvancedCollectionView : IAdvancedCollectionView, INotifyPropertyChanged, ISupportIncrementalLoading, IComparer +internal sealed class AdvancedCollectionView : IAdvancedCollectionView, INotifyPropertyChanged, ISupportIncrementalLoading, IComparer where T : class { private readonly List view; @@ -302,7 +302,7 @@ internal sealed class AdvancedCollectionView : IAdvancedCollectionView, IN return new NotificationDeferrer(this); } - int IComparer.Compare(T? x, T? y) + int IComparer.Compare(object? x, object? y) { if (sortProperties.Count <= 0) { @@ -329,7 +329,7 @@ internal sealed class AdvancedCollectionView : IAdvancedCollectionView, IN foreach (SortDescription sd in sortDescriptions) { - T? cx, cy; + object? cx, cy; if (string.IsNullOrEmpty(sd.PropertyName)) { @@ -340,8 +340,8 @@ internal sealed class AdvancedCollectionView : IAdvancedCollectionView, IN { PropertyInfo? pi = sortProperties[sd.PropertyName]; - cx = (T?)pi?.GetValue(x); - cy = (T?)pi?.GetValue(y); + cx = pi?.GetValue(x); + cy = pi?.GetValue(y); } int cmp = sd.Comparer.Compare(cx, cy);