1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2025-02-08 07:27:03 +00:00
Sonarr/NzbDrone.Common/IEnumerableExtensions.cs

16 lines
441 B
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Common
{
2013-09-19 01:09:26 +00:00
public static class EnumerableExtensions
{
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)));
}
}
}