Average.Generated.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. using System.Collections.Generic;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace System.Linq
  8. {
  9. public static partial class AsyncEnumerable
  10. {
  11. public static Task<double> Average(this IAsyncEnumerable<int> source)
  12. {
  13. if (source == null)
  14. throw new ArgumentNullException(nameof(source));
  15. return Average_(source, CancellationToken.None);
  16. }
  17. public static Task<double> Average(this IAsyncEnumerable<int> source, CancellationToken cancellationToken)
  18. {
  19. if (source == null)
  20. throw new ArgumentNullException(nameof(source));
  21. return Average_(source, cancellationToken);
  22. }
  23. public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector)
  24. {
  25. if (source == null)
  26. throw new ArgumentNullException(nameof(source));
  27. if (selector == null)
  28. throw new ArgumentNullException(nameof(selector));
  29. return source.Select(selector).Average(CancellationToken.None);
  30. }
  31. public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector, CancellationToken cancellationToken)
  32. {
  33. if (source == null)
  34. throw new ArgumentNullException(nameof(source));
  35. if (selector == null)
  36. throw new ArgumentNullException(nameof(selector));
  37. return source.Select(selector).Average(cancellationToken);
  38. }
  39. public static Task<double> Average(this IAsyncEnumerable<long> source)
  40. {
  41. if (source == null)
  42. throw new ArgumentNullException(nameof(source));
  43. return Average_(source, CancellationToken.None);
  44. }
  45. public static Task<double> Average(this IAsyncEnumerable<long> source, CancellationToken cancellationToken)
  46. {
  47. if (source == null)
  48. throw new ArgumentNullException(nameof(source));
  49. return Average_(source, cancellationToken);
  50. }
  51. public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector)
  52. {
  53. if (source == null)
  54. throw new ArgumentNullException(nameof(source));
  55. if (selector == null)
  56. throw new ArgumentNullException(nameof(selector));
  57. return source.Select(selector).Average(CancellationToken.None);
  58. }
  59. public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector, CancellationToken cancellationToken)
  60. {
  61. if (source == null)
  62. throw new ArgumentNullException(nameof(source));
  63. if (selector == null)
  64. throw new ArgumentNullException(nameof(selector));
  65. return source.Select(selector).Average(cancellationToken);
  66. }
  67. public static Task<float> Average(this IAsyncEnumerable<float> source)
  68. {
  69. if (source == null)
  70. throw new ArgumentNullException(nameof(source));
  71. return Average_(source, CancellationToken.None);
  72. }
  73. public static Task<float> Average(this IAsyncEnumerable<float> source, CancellationToken cancellationToken)
  74. {
  75. if (source == null)
  76. throw new ArgumentNullException(nameof(source));
  77. return Average_(source, cancellationToken);
  78. }
  79. public static Task<float> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector)
  80. {
  81. if (source == null)
  82. throw new ArgumentNullException(nameof(source));
  83. if (selector == null)
  84. throw new ArgumentNullException(nameof(selector));
  85. return source.Select(selector).Average(CancellationToken.None);
  86. }
  87. public static Task<float> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector, CancellationToken cancellationToken)
  88. {
  89. if (source == null)
  90. throw new ArgumentNullException(nameof(source));
  91. if (selector == null)
  92. throw new ArgumentNullException(nameof(selector));
  93. return source.Select(selector).Average(cancellationToken);
  94. }
  95. public static Task<double> Average(this IAsyncEnumerable<double> source)
  96. {
  97. if (source == null)
  98. throw new ArgumentNullException(nameof(source));
  99. return Average_(source, CancellationToken.None);
  100. }
  101. public static Task<double> Average(this IAsyncEnumerable<double> source, CancellationToken cancellationToken)
  102. {
  103. if (source == null)
  104. throw new ArgumentNullException(nameof(source));
  105. return Average_(source, cancellationToken);
  106. }
  107. public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector)
  108. {
  109. if (source == null)
  110. throw new ArgumentNullException(nameof(source));
  111. if (selector == null)
  112. throw new ArgumentNullException(nameof(selector));
  113. return source.Select(selector).Average(CancellationToken.None);
  114. }
  115. public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector, CancellationToken cancellationToken)
  116. {
  117. if (source == null)
  118. throw new ArgumentNullException(nameof(source));
  119. if (selector == null)
  120. throw new ArgumentNullException(nameof(selector));
  121. return source.Select(selector).Average(cancellationToken);
  122. }
  123. public static Task<decimal> Average(this IAsyncEnumerable<decimal> source)
  124. {
  125. if (source == null)
  126. throw new ArgumentNullException(nameof(source));
  127. return Average_(source, CancellationToken.None);
  128. }
  129. public static Task<decimal> Average(this IAsyncEnumerable<decimal> source, CancellationToken cancellationToken)
  130. {
  131. if (source == null)
  132. throw new ArgumentNullException(nameof(source));
  133. return Average_(source, cancellationToken);
  134. }
  135. public static Task<decimal> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector)
  136. {
  137. if (source == null)
  138. throw new ArgumentNullException(nameof(source));
  139. if (selector == null)
  140. throw new ArgumentNullException(nameof(selector));
  141. return source.Select(selector).Average(CancellationToken.None);
  142. }
  143. public static Task<decimal> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector, CancellationToken cancellationToken)
  144. {
  145. if (source == null)
  146. throw new ArgumentNullException(nameof(source));
  147. if (selector == null)
  148. throw new ArgumentNullException(nameof(selector));
  149. return source.Select(selector).Average(cancellationToken);
  150. }
  151. public static Task<double?> Average(this IAsyncEnumerable<int?> source)
  152. {
  153. if (source == null)
  154. throw new ArgumentNullException(nameof(source));
  155. return Average_(source, CancellationToken.None);
  156. }
  157. public static Task<double?> Average(this IAsyncEnumerable<int?> source, CancellationToken cancellationToken)
  158. {
  159. if (source == null)
  160. throw new ArgumentNullException(nameof(source));
  161. return Average_(source, cancellationToken);
  162. }
  163. public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector)
  164. {
  165. if (source == null)
  166. throw new ArgumentNullException(nameof(source));
  167. if (selector == null)
  168. throw new ArgumentNullException(nameof(selector));
  169. return source.Select(selector).Average(CancellationToken.None);
  170. }
  171. public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector, CancellationToken cancellationToken)
  172. {
  173. if (source == null)
  174. throw new ArgumentNullException(nameof(source));
  175. if (selector == null)
  176. throw new ArgumentNullException(nameof(selector));
  177. return source.Select(selector).Average(cancellationToken);
  178. }
  179. public static Task<double?> Average(this IAsyncEnumerable<long?> source)
  180. {
  181. if (source == null)
  182. throw new ArgumentNullException(nameof(source));
  183. return Average_(source, CancellationToken.None);
  184. }
  185. public static Task<double?> Average(this IAsyncEnumerable<long?> source, CancellationToken cancellationToken)
  186. {
  187. if (source == null)
  188. throw new ArgumentNullException(nameof(source));
  189. return Average_(source, cancellationToken);
  190. }
  191. public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector)
  192. {
  193. if (source == null)
  194. throw new ArgumentNullException(nameof(source));
  195. if (selector == null)
  196. throw new ArgumentNullException(nameof(selector));
  197. return source.Select(selector).Average(CancellationToken.None);
  198. }
  199. public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector, CancellationToken cancellationToken)
  200. {
  201. if (source == null)
  202. throw new ArgumentNullException(nameof(source));
  203. if (selector == null)
  204. throw new ArgumentNullException(nameof(selector));
  205. return source.Select(selector).Average(cancellationToken);
  206. }
  207. public static Task<float?> Average(this IAsyncEnumerable<float?> source)
  208. {
  209. if (source == null)
  210. throw new ArgumentNullException(nameof(source));
  211. return Average_(source, CancellationToken.None);
  212. }
  213. public static Task<float?> Average(this IAsyncEnumerable<float?> source, CancellationToken cancellationToken)
  214. {
  215. if (source == null)
  216. throw new ArgumentNullException(nameof(source));
  217. return Average_(source, cancellationToken);
  218. }
  219. public static Task<float?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector)
  220. {
  221. if (source == null)
  222. throw new ArgumentNullException(nameof(source));
  223. if (selector == null)
  224. throw new ArgumentNullException(nameof(selector));
  225. return source.Select(selector).Average(CancellationToken.None);
  226. }
  227. public static Task<float?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector, CancellationToken cancellationToken)
  228. {
  229. if (source == null)
  230. throw new ArgumentNullException(nameof(source));
  231. if (selector == null)
  232. throw new ArgumentNullException(nameof(selector));
  233. return source.Select(selector).Average(cancellationToken);
  234. }
  235. public static Task<double?> Average(this IAsyncEnumerable<double?> source)
  236. {
  237. if (source == null)
  238. throw new ArgumentNullException(nameof(source));
  239. return Average_(source, CancellationToken.None);
  240. }
  241. public static Task<double?> Average(this IAsyncEnumerable<double?> source, CancellationToken cancellationToken)
  242. {
  243. if (source == null)
  244. throw new ArgumentNullException(nameof(source));
  245. return Average_(source, cancellationToken);
  246. }
  247. public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector)
  248. {
  249. if (source == null)
  250. throw new ArgumentNullException(nameof(source));
  251. if (selector == null)
  252. throw new ArgumentNullException(nameof(selector));
  253. return source.Select(selector).Average(CancellationToken.None);
  254. }
  255. public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector, CancellationToken cancellationToken)
  256. {
  257. if (source == null)
  258. throw new ArgumentNullException(nameof(source));
  259. if (selector == null)
  260. throw new ArgumentNullException(nameof(selector));
  261. return source.Select(selector).Average(cancellationToken);
  262. }
  263. public static Task<decimal?> Average(this IAsyncEnumerable<decimal?> source)
  264. {
  265. if (source == null)
  266. throw new ArgumentNullException(nameof(source));
  267. return Average_(source, CancellationToken.None);
  268. }
  269. public static Task<decimal?> Average(this IAsyncEnumerable<decimal?> source, CancellationToken cancellationToken)
  270. {
  271. if (source == null)
  272. throw new ArgumentNullException(nameof(source));
  273. return Average_(source, cancellationToken);
  274. }
  275. public static Task<decimal?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector)
  276. {
  277. if (source == null)
  278. throw new ArgumentNullException(nameof(source));
  279. if (selector == null)
  280. throw new ArgumentNullException(nameof(selector));
  281. return source.Select(selector).Average(CancellationToken.None);
  282. }
  283. public static Task<decimal?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector, CancellationToken cancellationToken)
  284. {
  285. if (source == null)
  286. throw new ArgumentNullException(nameof(source));
  287. if (selector == null)
  288. throw new ArgumentNullException(nameof(selector));
  289. return source.Select(selector).Average(cancellationToken);
  290. }
  291. }
  292. }