AsyncPattern.Generated.tt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT 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. using System.Threading.Tasks;
  11. namespace System.Reactive.Joins
  12. {
  13. <#
  14. for (var i = 1; i <= 16; i++)
  15. {
  16. var genArgs = string.Join(", ", Enumerable.Range(1, i).Select(j => "TSource" + j));
  17. var args = string.Join(", ", Enumerable.Range(1, i).Select(j => "IAsyncObservable<TSource" + j + "> source" + j));
  18. #>
  19. public class AsyncPattern<<#=genArgs#>> : AsyncPattern
  20. {
  21. <#
  22. for (var j = 1; j <= i; j++)
  23. {
  24. #>
  25. internal IAsyncObservable<TSource<#=j#>> Source<#=j#> { get; }
  26. <#
  27. }
  28. #>
  29. internal AsyncPattern(<#=args#>)
  30. {
  31. <#
  32. for (var j = 1; j <= i; j++)
  33. {
  34. #>
  35. Source<#=j#> = source<#=j#>;
  36. <#
  37. }
  38. #>
  39. }
  40. public AsyncPlan<TResult> Then<TResult>(Func<<#=genArgs#>, TResult> selector)
  41. {
  42. if (selector == null)
  43. throw new ArgumentNullException(nameof(selector));
  44. return new AsyncPlan<<#=genArgs#>, TResult>(this, selector);
  45. }
  46. public AsyncPlan<TResult> Then<TResult>(Func<<#=genArgs#>, ValueTask<TResult>> selector)
  47. {
  48. if (selector == null)
  49. throw new ArgumentNullException(nameof(selector));
  50. return new AsyncPlanWithTask<<#=genArgs#>, TResult>(this, selector);
  51. }
  52. }
  53. <#
  54. }
  55. #>
  56. }