// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. <#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".Generated.cs" #> namespace System.Reactive.Joins { /* The following code is generated by a T4 template. */ #region Joins auto-generated code (<#=DateTime.Now#>) <# Func toUpper = s => char.ToUpper(s[0]) + s.Substring(1); string[] counts = new[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen" }; string[] ordinals = new[] { "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth" }; for (int i = 1; i <= 16; i++) { var parameters = string.Join(", ", Enumerable.Range(1, i).Select(j => "IObservable " + ordinals[j - 1])); var genArgs = string.Join(", ", Enumerable.Range(1, i).Select(j => "TSource" + j)); var sources = string.Join(", ", Enumerable.Range(1, i).Select(j => toUpper(ordinals[j - 1]))); #> /// /// Represents a join pattern over <#=counts[i - 1]#> observable sequence<#=i != 1 ? "s" : ""#>. /// <# for (int j = 0; j < i; j++) { #> /// The type of the elements in the <#=ordinals[j]#> source sequence. <# } #> public class Pattern<<#=genArgs#>> : Pattern { internal Pattern(<#=parameters#>) { <# for (int j = 0; j < i; j++) { #> <#=toUpper(ordinals[j])#> = <#=ordinals[j]#>; <# } #> } <# for (int j = 0; j < i; j++) { #> internal IObservable> <#=toUpper(ordinals[j])#> { get; } <# } #> <# if (i > 1 && i != 16) { #> /// /// Creates a pattern that matches when all <#=counts[i]#> observable sequences have an available element. /// /// The type of the elements in the <#=ordinals[i]#> observable sequence. /// Observable sequence to match with the <#=counts[i - 1]#> previous sequences. /// Pattern object that matches when all observable sequences have an available element. /// is null. public Pattern<<#=genArgs#>, TSource<#=i+1#>> And>(IObservable> other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } return new Pattern<<#=genArgs#>, TSource<#=i+1#>>(<#=sources#>, other); } <# } #> /// /// Matches when all observable sequences have an available element and projects the elements by invoking the selector function. /// /// The type of the elements in the result sequence, returned by the selector function. /// Selector that will be invoked for elements in the source sequences. /// Plan that produces the projected results, to be fed (with other plans) to the When operator. /// is null. public Plan Then(Func<<#=genArgs#>, TResult> selector) { if (selector == null) { throw new ArgumentNullException(nameof(selector)); } return new Plan<<#=genArgs#>, TResult>(this, selector); } } <# } #> #endregion }