//The MIT License (MIT)
//http://arolibraries.codeplex.com/license
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
namespace AroLibraries.ExtensionMethods.Enumerable
{
public static class IEnumerableExt
{
public static IEnumerable> Ext_Split(this IEnumerable source, int splitSize)
{
using (IEnumerator enumerator = source.GetEnumerator())
{
while (enumerator.MoveNext())
{
yield return Ext_SplitInner(enumerator, splitSize);
}
}
}
private static IEnumerable Ext_SplitInner(IEnumerator enumerator, int splitSize)
{
int count = 0;
do
{
count++;
yield return enumerator.Current;
}
while (count % splitSize != 0
&& enumerator.MoveNext());
}
}
}