mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-30 19:56:54 +00:00
16 lines
442 B
C#
16 lines
442 B
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
|
||
|
namespace NzbDrone.Common
|
||
|
{
|
||
|
public static class IEnumerableExtensions
|
||
|
{
|
||
|
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||
|
{
|
||
|
var knownKeys = new HashSet<TKey>();
|
||
|
|
||
|
return source.Where(element => knownKeys.Add(keySelector(element)));
|
||
|
}
|
||
|
}
|
||
|
}
|