<#@ template language="C#" #>// #if FAT using System; using System.Collections.Generic; namespace LinqInternal.Collections { internal static partial class Extensions { #if NET35 public static IEnumerable Zip(this IEnumerable first, IEnumerable second, Func resultSelector) #else public static IEnumerable Zip(IEnumerable first, IEnumerable second, Func 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 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 obj<# else for (var subindice = 1; subindice <= indice; subindice++){ if (subindice != 1) {#>, <#}#>IEnumerable> 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