AsyncPattern.Generated.tt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. <#@ template debug="false" hostspecific="false" language="C#" #>
  5. <#@ assembly name="System.Core" #>
  6. <#@ import namespace="System.Linq" #>
  7. <#@ import namespace="System.Text" #>
  8. <#@ import namespace="System.Collections.Generic" #>
  9. <#@ output extension=".cs" #>
  10. namespace System.Reactive.Joins
  11. {
  12. <#
  13. for (var i = 1; i <= 16; i++)
  14. {
  15. var genArgs = string.Join(", ", Enumerable.Range(1, i).Select(j => "TSource" + j));
  16. var args = string.Join(", ", Enumerable.Range(1, i).Select(j => "IAsyncObservable<TSource" + j + "> source" + j));
  17. #>
  18. public class AsyncPattern<<#=genArgs#>> : AsyncPattern
  19. {
  20. <#
  21. for (var j = 1; j <= i; j++)
  22. {
  23. #>
  24. internal IAsyncObservable<TSource<#=j#>> Source<#=j#> { get; }
  25. <#
  26. }
  27. #>
  28. internal AsyncPattern(<#=args#>)
  29. {
  30. <#
  31. for (var j = 1; j <= i; j++)
  32. {
  33. #>
  34. Source<#=j#> = source<#=j#>;
  35. <#
  36. }
  37. #>
  38. }
  39. public AsyncPlan<TResult> Then<TResult>(Func<<#=genArgs#>, TResult> selector)
  40. {
  41. if (selector == null)
  42. throw new ArgumentNullException(nameof(selector));
  43. return new AsyncPlan<<#=genArgs#>, TResult>(this, selector);
  44. }
  45. }
  46. <#
  47. }
  48. #>
  49. }