You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
5 years ago
|
// Needed for NET40
|
||
|
#if !NET_4_6
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace LinqInternal.Collections
|
||
|
{
|
||
|
internal static partial class Extensions
|
||
|
{
|
||
|
public static int AddRange<T>(this ICollection<T> collection, IEnumerable<T> items)
|
||
|
{
|
||
|
if (collection == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("collection");
|
||
|
}
|
||
|
if (items == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("items");
|
||
|
}
|
||
|
var count = 0;
|
||
|
foreach (var item in items)
|
||
|
{
|
||
|
collection.Add(item);
|
||
|
count++;
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
|
||
|
public static IEnumerable<T> AddRangeEnumerable<T>(this ICollection<T> collection, IEnumerable<T> items)
|
||
|
{
|
||
|
if (collection == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("collection");
|
||
|
}
|
||
|
if (items == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("items");
|
||
|
}
|
||
|
foreach (var item in items)
|
||
|
{
|
||
|
collection.Add(item);
|
||
|
yield return item;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endif
|