aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Extensions/LinqExtensions.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-08-09 15:56:38 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-08-09 15:56:38 -0400
commit40442f887ba717ae47620b152315f21b252fe049 (patch)
tree340be082fd2296f19aed17b24b22b5095e3815a7 /MediaBrowser.Model/Extensions/LinqExtensions.cs
parent52aeb3c40b3e2f0fdc377ac7c793714add2be0ef (diff)
consolidate emby.server.core into emby.server.implementations
Diffstat (limited to 'MediaBrowser.Model/Extensions/LinqExtensions.cs')
-rw-r--r--MediaBrowser.Model/Extensions/LinqExtensions.cs26
1 files changed, 26 insertions, 0 deletions
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<TSource>(this IEnumerable<TSource> 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<TSource> ToList<TSource>(this IEnumerable<TSource> source, int count)
+ {
+ if (source == null) throw new ArgumentNullException("source");
+ if (count < 0) throw new ArgumentOutOfRangeException("count");
+ var array = new List<TSource>(count);
+ int i = 0;
+ foreach (var item in source)
+ {
+ array[i++] = item;
+ }
+ return array;
+ }
+
/// <summary>
/// Returns all distinct elements of the given source, where "distinctness"
/// is determined via a projection and the specified comparer for the projected type.