From 40442f887ba717ae47620b152315f21b252fe049 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 9 Aug 2017 15:56:38 -0400 Subject: consolidate emby.server.core into emby.server.implementations --- MediaBrowser.Model/Extensions/LinqExtensions.cs | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'MediaBrowser.Model/Extensions') diff --git a/MediaBrowser.Model/Extensions/LinqExtensions.cs b/MediaBrowser.Model/Extensions/LinqExtensions.cs index 6b2bdb4c7..43e4a66cd 100644 --- a/MediaBrowser.Model/Extensions/LinqExtensions.cs +++ b/MediaBrowser.Model/Extensions/LinqExtensions.cs @@ -42,6 +42,32 @@ namespace MediaBrowser.Model.Extensions return source.DistinctBy(keySelector, null); } + public static TSource[] ToArray(this IEnumerable source, int count) + { + if (source == null) throw new ArgumentNullException("source"); + if (count < 0) throw new ArgumentOutOfRangeException("count"); + var array = new TSource[count]; + int i = 0; + foreach (var item in source) + { + array[i++] = item; + } + return array; + } + + public static List ToList(this IEnumerable source, int count) + { + if (source == null) throw new ArgumentNullException("source"); + if (count < 0) throw new ArgumentOutOfRangeException("count"); + var array = new List(count); + int i = 0; + foreach (var item in source) + { + array[i++] = item; + } + return array; + } + /// /// Returns all distinct elements of the given source, where "distinctness" /// is determined via a projection and the specified comparer for the projected type. -- cgit v1.2.3