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.
99 lines
3.2 KiB
99 lines
3.2 KiB
<#@ template language="C#" #>// <auto-generated /> |
|
|
|
#if FAT |
|
|
|
using System; |
|
using System.Collections.Generic; |
|
|
|
namespace LinqInternal.Collections |
|
{ |
|
internal static partial class Extensions |
|
{ |
|
#if NET35 |
|
public static IEnumerable<TReturn> Zip<T1, T2, TReturn>(this IEnumerable<T1> first, IEnumerable<T2> second, Func<T1, T2, TReturn> resultSelector) |
|
#else |
|
public static IEnumerable<TReturn> Zip<T1, T2, TReturn>(IEnumerable<T1> first, IEnumerable<T2> second, Func<T1, T2, TReturn> resultSelector) |
|
#endif |
|
{ |
|
if (first == null) |
|
{ |
|
throw new ArgumentNullException("first"); |
|
} |
|
if (second == null) |
|
{ |
|
throw new ArgumentNullException("second"); |
|
} |
|
if (resultSelector == null) |
|
{ |
|
throw new ArgumentNullException("resultSelector"); |
|
} |
|
using (var enumerator1 = first.GetEnumerator()) |
|
using (var enumerator2 = second.GetEnumerator()) |
|
{ |
|
while |
|
( |
|
enumerator1.MoveNext() |
|
&& enumerator2.MoveNext() |
|
) |
|
{ |
|
yield return resultSelector |
|
( |
|
enumerator1.Current, |
|
enumerator2.Current |
|
); |
|
} |
|
} |
|
} |
|
<# |
|
for (var indice = 3; indice < 17; indice++) |
|
{#> |
|
|
|
public static IEnumerable<TReturn> Zip<<# if (indice != 0) { if (indice == 1) #>T<# else for (var subindice = 1; subindice <= indice; subindice++){ if (subindice != 1) {#>, <#}#>T<#=subindice#><#}#>, <#}#>TReturn>(<# if (indice != 0) { if (indice == 1) #>IEnumerable<T> obj<# else for (var subindice = 1; subindice <= indice; subindice++){ if (subindice != 1) {#>, <#}#>IEnumerable<T<#=subindice#>> arg<#=subindice#><#}}#>, Func<<# if (indice != 0) { if (indice == 1) #>T<# else for (var subindice = 1; subindice <= indice; subindice++){ if (subindice != 1) {#>, <#}#>T<#=subindice#><#}#>, <#}#>TReturn> resultSelector) |
|
{ |
|
<# |
|
for (var subindice = 1; subindice <= indice; subindice++) |
|
{#> |
|
if (arg<#=subindice#> == null) |
|
{ |
|
throw new ArgumentNullException("arg<#=subindice#>"); |
|
} |
|
<# |
|
}#> |
|
if (resultSelector == null) |
|
{ |
|
throw new ArgumentNullException("resultSelector"); |
|
} |
|
<# |
|
for (var subindice = 1; subindice <= indice; subindice++) |
|
{#> |
|
using (var enumerator<#=subindice#> = arg<#=subindice#>.GetEnumerator()) |
|
<# |
|
}#> |
|
{ |
|
while |
|
( |
|
<# |
|
for (var subindice = 1; subindice <= indice; subindice++) |
|
{#> |
|
<#= subindice == 1 ? "" : "&& " #>enumerator<#=subindice#>.MoveNext() |
|
<# |
|
}#> |
|
) |
|
{ |
|
yield return resultSelector |
|
( |
|
<# |
|
for (var subindice = 1; subindice <= indice; subindice++) |
|
{#> |
|
enumerator<#=subindice#>.Current<#= subindice == indice ? "" : "," #> |
|
<# |
|
}#> |
|
); |
|
} |
|
} |
|
} |
|
<# |
|
}#> } |
|
} |
|
|
|
#endif |