Skip to content

Commit

Permalink
Use generic arguments if possible to get type of elements in lists
Browse files Browse the repository at this point in the history
  • Loading branch information
lhak authored and Arlodotexe committed Aug 23, 2023
1 parent a9fdaab commit 72bf0b1
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,18 @@ int IComparer<object>.Compare(object x, object y)
{
if (!_sortProperties.Any())
{
var type = x.GetType();
var listType = _source?.GetType();
Type type;

if (listType != null && listType.IsGenericType)
{
type = listType.GetGenericArguments()[0];
}
else
{
type = x.GetType();
}

foreach (var sd in _sortDescriptions)
{
if (!string.IsNullOrEmpty(sd.PropertyName))
Expand Down

0 comments on commit 72bf0b1

Please sign in to comment.