| 1 |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. |
| 2 |
using System.Collections.Generic; |
| 3 |
using System.Threading; |
| 4 |
using System.Threading.Tasks; |
| 5 |
|
| 6 |
namespace System.Linq |
| 7 |
{ |
| 8 |
public static partial class AsyncEnumerable |
| 9 |
{ |
| 10 |
public static Task<decimal?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector) |
| 11 |
{ |
| 12 |
if (source == null) |
| 13 |
throw new ArgumentNullException("source"); |
| 14 |
if (selector == null) |
| 15 |
throw new ArgumentNullException("selector"); |
| 16 |
|
| 17 |
return Min(source, selector, CancellationToken.None); |
| 18 |
} |
| 19 |
|
| 20 |
public static Task<TResult> Min<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector) |
| 21 |
{ |
| 22 |
if (source == null) |
| 23 |
throw new ArgumentNullException("source"); |
| 24 |
if (selector == null) |
| 25 |
throw new ArgumentNullException("selector"); |
| 26 |
|
| 27 |
return Min(source, selector, CancellationToken.None); |
| 28 |
} |
| 29 |
|
| 30 |
public static Task<int> Sum(this IAsyncEnumerable<int> source) |
| 31 |
{ |
| 32 |
if (source == null) |
| 33 |
throw new ArgumentNullException("source"); |
| 34 |
|
| 35 |
return Sum(source, CancellationToken.None); |
| 36 |
} |
| 37 |
|
| 38 |
public static Task<long> Sum(this IAsyncEnumerable<long> source) |
| 39 |
{ |
| 40 |
if (source == null) |
| 41 |
throw new ArgumentNullException("source"); |
| 42 |
|
| 43 |
return Sum(source, CancellationToken.None); |
| 44 |
} |
| 45 |
|
| 46 |
public static Task<double> Sum(this IAsyncEnumerable<double> source) |
| 47 |
{ |
| 48 |
if (source == null) |
| 49 |
throw new ArgumentNullException("source"); |
| 50 |
|
| 51 |
return Sum(source, CancellationToken.None); |
| 52 |
} |
| 53 |
|
| 54 |
public static Task<float> Sum(this IAsyncEnumerable<float> source) |
| 55 |
{ |
| 56 |
if (source == null) |
| 57 |
throw new ArgumentNullException("source"); |
| 58 |
|
| 59 |
return Sum(source, CancellationToken.None); |
| 60 |
} |
| 61 |
|
| 62 |
public static Task<decimal> Sum(this IAsyncEnumerable<decimal> source) |
| 63 |
{ |
| 64 |
if (source == null) |
| 65 |
throw new ArgumentNullException("source"); |
| 66 |
|
| 67 |
return Sum(source, CancellationToken.None); |
| 68 |
} |
| 69 |
|
| 70 |
public static Task<int?> Sum(this IAsyncEnumerable<int?> source) |
| 71 |
{ |
| 72 |
if (source == null) |
| 73 |
throw new ArgumentNullException("source"); |
| 74 |
|
| 75 |
return Sum(source, CancellationToken.None); |
| 76 |
} |
| 77 |
|
| 78 |
public static Task<long?> Sum(this IAsyncEnumerable<long?> source) |
| 79 |
{ |
| 80 |
if (source == null) |
| 81 |
throw new ArgumentNullException("source"); |
| 82 |
|
| 83 |
return Sum(source, CancellationToken.None); |
| 84 |
} |
| 85 |
|
| 86 |
public static Task<double?> Sum(this IAsyncEnumerable<double?> source) |
| 87 |
{ |
| 88 |
if (source == null) |
| 89 |
throw new ArgumentNullException("source"); |
| 90 |
|
| 91 |
return Sum(source, CancellationToken.None); |
| 92 |
} |
| 93 |
|
| 94 |
public static Task<float?> Sum(this IAsyncEnumerable<float?> source) |
| 95 |
{ |
| 96 |
if (source == null) |
| 97 |
throw new ArgumentNullException("source"); |
| 98 |
|
| 99 |
return Sum(source, CancellationToken.None); |
| 100 |
} |
| 101 |
|
| 102 |
public static Task<decimal?> Sum(this IAsyncEnumerable<decimal?> source) |
| 103 |
{ |
| 104 |
if (source == null) |
| 105 |
throw new ArgumentNullException("source"); |
| 106 |
|
| 107 |
return Sum(source, CancellationToken.None); |
| 108 |
} |
| 109 |
|
| 110 |
public static Task<int> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector) |
| 111 |
{ |
| 112 |
if (source == null) |
| 113 |
throw new ArgumentNullException("source"); |
| 114 |
if (selector == null) |
| 115 |
throw new ArgumentNullException("selector"); |
| 116 |
|
| 117 |
return Sum(source, selector, CancellationToken.None); |
| 118 |
} |
| 119 |
|
| 120 |
public static Task<long> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector) |
| 121 |
{ |
| 122 |
if (source == null) |
| 123 |
throw new ArgumentNullException("source"); |
| 124 |
if (selector == null) |
| 125 |
throw new ArgumentNullException("selector"); |
| 126 |
|
| 127 |
return Sum(source, selector, CancellationToken.None); |
| 128 |
} |
| 129 |
|
| 130 |
public static Task<double> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector) |
| 131 |
{ |
| 132 |
if (source == null) |
| 133 |
throw new ArgumentNullException("source"); |
| 134 |
if (selector == null) |
| 135 |
throw new ArgumentNullException("selector"); |
| 136 |
|
| 137 |
return Sum(source, selector, CancellationToken.None); |
| 138 |
} |
| 139 |
|
| 140 |
public static Task<float> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector) |
| 141 |
{ |
| 142 |
if (source == null) |
| 143 |
throw new ArgumentNullException("source"); |
| 144 |
if (selector == null) |
| 145 |
throw new ArgumentNullException("selector"); |
| 146 |
|
| 147 |
return Sum(source, selector, CancellationToken.None); |
| 148 |
} |
| 149 |
|
| 150 |
public static Task<decimal> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector) |
| 151 |
{ |
| 152 |
if (source == null) |
| 153 |
throw new ArgumentNullException("source"); |
| 154 |
if (selector == null) |
| 155 |
throw new ArgumentNullException("selector"); |
| 156 |
|
| 157 |
return Sum(source, selector, CancellationToken.None); |
| 158 |
} |
| 159 |
|
| 160 |
public static Task<int?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector) |
| 161 |
{ |
| 162 |
if (source == null) |
| 163 |
throw new ArgumentNullException("source"); |
| 164 |
if (selector == null) |
| 165 |
throw new ArgumentNullException("selector"); |
| 166 |
|
| 167 |
return Sum(source, selector, CancellationToken.None); |
| 168 |
} |
| 169 |
|
| 170 |
public static Task<long?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector) |
| 171 |
{ |
| 172 |
if (source == null) |
| 173 |
throw new ArgumentNullException("source"); |
| 174 |
if (selector == null) |
| 175 |
throw new ArgumentNullException("selector"); |
| 176 |
|
| 177 |
return Sum(source, selector, CancellationToken.None); |
| 178 |
} |
| 179 |
|
| 180 |
public static Task<double?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector) |
| 181 |
{ |
| 182 |
if (source == null) |
| 183 |
throw new ArgumentNullException("source"); |
| 184 |
if (selector == null) |
| 185 |
throw new ArgumentNullException("selector"); |
| 186 |
|
| 187 |
return Sum(source, selector, CancellationToken.None); |
| 188 |
} |
| 189 |
|
| 190 |
public static Task<float?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector) |
| 191 |
{ |
| 192 |
if (source == null) |
| 193 |
throw new ArgumentNullException("source"); |
| 194 |
if (selector == null) |
| 195 |
throw new ArgumentNullException("selector"); |
| 196 |
|
| 197 |
return Sum(source, selector, CancellationToken.None); |
| 198 |
} |
| 199 |
|
| 200 |
public static Task<decimal?> Sum<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector) |
| 201 |
{ |
| 202 |
if (source == null) |
| 203 |
throw new ArgumentNullException("source"); |
| 204 |
if (selector == null) |
| 205 |
throw new ArgumentNullException("selector"); |
| 206 |
|
| 207 |
return Sum(source, selector, CancellationToken.None); |
| 208 |
} |
| 209 |
|
| 210 |
public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action) |
| 211 |
{ |
| 212 |
if (source == null) |
| 213 |
throw new ArgumentNullException("source"); |
| 214 |
if (action == null) |
| 215 |
throw new ArgumentNullException("action"); |
| 216 |
|
| 217 |
source.ForEachAsync(action).Wait(); |
| 218 |
} |
| 219 |
|
| 220 |
public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action) |
| 221 |
{ |
| 222 |
if (source == null) |
| 223 |
throw new ArgumentNullException("source"); |
| 224 |
if (action == null) |
| 225 |
throw new ArgumentNullException("action"); |
| 226 |
|
| 227 |
return ForEachAsync(source, action, CancellationToken.None); |
| 228 |
} |
| 229 |
|
| 230 |
public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action) |
| 231 |
{ |
| 232 |
if (source == null) |
| 233 |
throw new ArgumentNullException("source"); |
| 234 |
if (action == null) |
| 235 |
throw new ArgumentNullException("action"); |
| 236 |
|
| 237 |
source.ForEachAsync(action).Wait(); |
| 238 |
} |
| 239 |
|
| 240 |
public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action) |
| 241 |
{ |
| 242 |
if (source == null) |
| 243 |
throw new ArgumentNullException("source"); |
| 244 |
if (action == null) |
| 245 |
throw new ArgumentNullException("action"); |
| 246 |
|
| 247 |
return ForEachAsync(source, action, CancellationToken.None); |
| 248 |
} |
| 249 |
|
| 250 |
public static Task<double> Average(this IAsyncEnumerable<long> source) |
| 251 |
{ |
| 252 |
if (source == null) |
| 253 |
throw new ArgumentNullException("source"); |
| 254 |
|
| 255 |
return Average(source, CancellationToken.None); |
| 256 |
} |
| 257 |
|
| 258 |
public static Task<double?> Average(this IAsyncEnumerable<long?> source) |
| 259 |
{ |
| 260 |
if (source == null) |
| 261 |
throw new ArgumentNullException("source"); |
| 262 |
|
| 263 |
return Average(source, CancellationToken.None); |
| 264 |
} |
| 265 |
|
| 266 |
public static Task<double> Average(this IAsyncEnumerable<double> source) |
| 267 |
{ |
| 268 |
if (source == null) |
| 269 |
throw new ArgumentNullException("source"); |
| 270 |
|
| 271 |
return Average(source, CancellationToken.None); |
| 272 |
} |
| 273 |
|
| 274 |
public static Task<double?> Average(this IAsyncEnumerable<double?> source) |
| 275 |
{ |
| 276 |
if (source == null) |
| 277 |
throw new ArgumentNullException("source"); |
| 278 |
|
| 279 |
return Average(source, CancellationToken.None); |
| 280 |
} |
| 281 |
|
| 282 |
public static Task<float> Average(this IAsyncEnumerable<float> source) |
| 283 |
{ |
| 284 |
if (source == null) |
| 285 |
throw new ArgumentNullException("source"); |
| 286 |
|
| 287 |
return Average(source, CancellationToken.None); |
| 288 |
} |
| 289 |
|
| 290 |
public static Task<float?> Average(this IAsyncEnumerable<float?> source) |
| 291 |
{ |
| 292 |
if (source == null) |
| 293 |
throw new ArgumentNullException("source"); |
| 294 |
|
| 295 |
return Average(source, CancellationToken.None); |
| 296 |
} |
| 297 |
|
| 298 |
public static Task<decimal> Average(this IAsyncEnumerable<decimal> source) |
| 299 |
{ |
| 300 |
if (source == null) |
| 301 |
throw new ArgumentNullException("source"); |
| 302 |
|
| 303 |
return Average(source, CancellationToken.None); |
| 304 |
} |
| 305 |
|
| 306 |
public static Task<decimal?> Average(this IAsyncEnumerable<decimal?> source) |
| 307 |
{ |
| 308 |
if (source == null) |
| 309 |
throw new ArgumentNullException("source"); |
| 310 |
|
| 311 |
return Average(source, CancellationToken.None); |
| 312 |
} |
| 313 |
|
| 314 |
public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector) |
| 315 |
{ |
| 316 |
if (source == null) |
| 317 |
throw new ArgumentNullException("source"); |
| 318 |
if (selector == null) |
| 319 |
throw new ArgumentNullException("selector"); |
| 320 |
|
| 321 |
return Average(source, selector, CancellationToken.None); |
| 322 |
} |
| 323 |
|
| 324 |
public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector) |
| 325 |
{ |
| 326 |
if (source == null) |
| 327 |
throw new ArgumentNullException("source"); |
| 328 |
if (selector == null) |
| 329 |
throw new ArgumentNullException("selector"); |
| 330 |
|
| 331 |
return Average(source, selector, CancellationToken.None); |
| 332 |
} |
| 333 |
|
| 334 |
public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector) |
| 335 |
{ |
| 336 |
if (source == null) |
| 337 |
throw new ArgumentNullException("source"); |
| 338 |
if (selector == null) |
| 339 |
throw new ArgumentNullException("selector"); |
| 340 |
|
| 341 |
return Average(source, selector, CancellationToken.None); |
| 342 |
} |
| 343 |
|
| 344 |
public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector) |
| 345 |
{ |
| 346 |
if (source == null) |
| 347 |
throw new ArgumentNullException("source"); |
| 348 |
if (selector == null) |
| 349 |
throw new ArgumentNullException("selector"); |
| 350 |
|
| 351 |
return Average(source, selector, CancellationToken.None); |
| 352 |
} |
| 353 |
|
| 354 |
public static Task<double> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector) |
| 355 |
{ |
| 356 |
if (source == null) |
| 357 |
throw new ArgumentNullException("source"); |
| 358 |
if (selector == null) |
| 359 |
throw new ArgumentNullException("selector"); |
| 360 |
|
| 361 |
return Average(source, selector, CancellationToken.None); |
| 362 |
} |
| 363 |
|
| 364 |
public static Task<double?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector) |
| 365 |
{ |
| 366 |
if (source == null) |
| 367 |
throw new ArgumentNullException("source"); |
| 368 |
if (selector == null) |
| 369 |
throw new ArgumentNullException("selector"); |
| 370 |
|
| 371 |
return Average(source, selector, CancellationToken.None); |
| 372 |
} |
| 373 |
|
| 374 |
public static Task<float> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector) |
| 375 |
{ |
| 376 |
if (source == null) |
| 377 |
throw new ArgumentNullException("source"); |
| 378 |
if (selector == null) |
| 379 |
throw new ArgumentNullException("selector"); |
| 380 |
|
| 381 |
return Average(source, selector, CancellationToken.None); |
| 382 |
} |
| 383 |
|
| 384 |
public static Task<float?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector) |
| 385 |
{ |
| 386 |
if (source == null) |
| 387 |
throw new ArgumentNullException("source"); |
| 388 |
if (selector == null) |
| 389 |
throw new ArgumentNullException("selector"); |
| 390 |
|
| 391 |
return Average(source, selector, CancellationToken.None); |
| 392 |
} |
| 393 |
|
| 394 |
public static Task<decimal> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector) |
| 395 |
{ |
| 396 |
if (source == null) |
| 397 |
throw new ArgumentNullException("source"); |
| 398 |
if (selector == null) |
| 399 |
throw new ArgumentNullException("selector"); |
| 400 |
|
| 401 |
return Average(source, selector, CancellationToken.None); |
| 402 |
} |
| 403 |
|
| 404 |
public static Task<decimal?> Average<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector) |
| 405 |
{ |
| 406 |
if (source == null) |
| 407 |
throw new ArgumentNullException("source"); |
| 408 |
if (selector == null) |
| 409 |
throw new ArgumentNullException("selector"); |
| 410 |
|
| 411 |
return Average(source, selector, CancellationToken.None); |
| 412 |
} |
| 413 |
|
| 414 |
public static Task<int> Max(this IAsyncEnumerable<int> source) |
| 415 |
{ |
| 416 |
if (source == null) |
| 417 |
throw new ArgumentNullException("source"); |
| 418 |
|
| 419 |
return Max(source, CancellationToken.None); |
| 420 |
} |
| 421 |
|
| 422 |
public static Task<long> Max(this IAsyncEnumerable<long> source) |
| 423 |
{ |
| 424 |
if (source == null) |
| 425 |
throw new ArgumentNullException("source"); |
| 426 |
|
| 427 |
return Max(source, CancellationToken.None); |
| 428 |
} |
| 429 |
|
| 430 |
public static Task<double> Max(this IAsyncEnumerable<double> source) |
| 431 |
{ |
| 432 |
if (source == null) |
| 433 |
throw new ArgumentNullException("source"); |
| 434 |
|
| 435 |
return Max(source, CancellationToken.None); |
| 436 |
} |
| 437 |
|
| 438 |
public static Task<float> Max(this IAsyncEnumerable<float> source) |
| 439 |
{ |
| 440 |
if (source == null) |
| 441 |
throw new ArgumentNullException("source"); |
| 442 |
|
| 443 |
return Max(source, CancellationToken.None); |
| 444 |
} |
| 445 |
|
| 446 |
public static Task<decimal> Max(this IAsyncEnumerable<decimal> source) |
| 447 |
{ |
| 448 |
if (source == null) |
| 449 |
throw new ArgumentNullException("source"); |
| 450 |
|
| 451 |
return Max(source, CancellationToken.None); |
| 452 |
} |
| 453 |
|
| 454 |
public static Task<int?> Max(this IAsyncEnumerable<int?> source) |
| 455 |
{ |
| 456 |
if (source == null) |
| 457 |
throw new ArgumentNullException("source"); |
| 458 |
|
| 459 |
return Max(source, CancellationToken.None); |
| 460 |
} |
| 461 |
|
| 462 |
public static Task<long?> Max(this IAsyncEnumerable<long?> source) |
| 463 |
{ |
| 464 |
if (source == null) |
| 465 |
throw new ArgumentNullException("source"); |
| 466 |
|
| 467 |
return Max(source, CancellationToken.None); |
| 468 |
} |
| 469 |
|
| 470 |
public static Task<double?> Max(this IAsyncEnumerable<double?> source) |
| 471 |
{ |
| 472 |
if (source == null) |
| 473 |
throw new ArgumentNullException("source"); |
| 474 |
|
| 475 |
return Max(source, CancellationToken.None); |
| 476 |
} |
| 477 |
|
| 478 |
public static Task<float?> Max(this IAsyncEnumerable<float?> source) |
| 479 |
{ |
| 480 |
if (source == null) |
| 481 |
throw new ArgumentNullException("source"); |
| 482 |
|
| 483 |
return Max(source, CancellationToken.None); |
| 484 |
} |
| 485 |
|
| 486 |
public static Task<decimal?> Max(this IAsyncEnumerable<decimal?> source) |
| 487 |
{ |
| 488 |
if (source == null) |
| 489 |
throw new ArgumentNullException("source"); |
| 490 |
|
| 491 |
return Max(source, CancellationToken.None); |
| 492 |
} |
| 493 |
|
| 494 |
public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source) |
| 495 |
{ |
| 496 |
if (source == null) |
| 497 |
throw new ArgumentNullException("source"); |
| 498 |
|
| 499 |
return Max(source, CancellationToken.None); |
| 500 |
} |
| 501 |
|
| 502 |
public static Task<int> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector) |
| 503 |
{ |
| 504 |
if (source == null) |
| 505 |
throw new ArgumentNullException("source"); |
| 506 |
if (selector == null) |
| 507 |
throw new ArgumentNullException("selector"); |
| 508 |
|
| 509 |
return Max(source, selector, CancellationToken.None); |
| 510 |
} |
| 511 |
|
| 512 |
public static Task<long> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector) |
| 513 |
{ |
| 514 |
if (source == null) |
| 515 |
throw new ArgumentNullException("source"); |
| 516 |
if (selector == null) |
| 517 |
throw new ArgumentNullException("selector"); |
| 518 |
|
| 519 |
return Max(source, selector, CancellationToken.None); |
| 520 |
} |
| 521 |
|
| 522 |
public static Task<double> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector) |
| 523 |
{ |
| 524 |
if (source == null) |
| 525 |
throw new ArgumentNullException("source"); |
| 526 |
if (selector == null) |
| 527 |
throw new ArgumentNullException("selector"); |
| 528 |
|
| 529 |
return Max(source, selector, CancellationToken.None); |
| 530 |
} |
| 531 |
|
| 532 |
public static Task<float> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector) |
| 533 |
{ |
| 534 |
if (source == null) |
| 535 |
throw new ArgumentNullException("source"); |
| 536 |
if (selector == null) |
| 537 |
throw new ArgumentNullException("selector"); |
| 538 |
|
| 539 |
return Max(source, selector, CancellationToken.None); |
| 540 |
} |
| 541 |
|
| 542 |
public static Task<decimal> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector) |
| 543 |
{ |
| 544 |
if (source == null) |
| 545 |
throw new ArgumentNullException("source"); |
| 546 |
if (selector == null) |
| 547 |
throw new ArgumentNullException("selector"); |
| 548 |
|
| 549 |
return Max(source, selector, CancellationToken.None); |
| 550 |
} |
| 551 |
|
| 552 |
public static Task<int?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector) |
| 553 |
{ |
| 554 |
if (source == null) |
| 555 |
throw new ArgumentNullException("source"); |
| 556 |
if (selector == null) |
| 557 |
throw new ArgumentNullException("selector"); |
| 558 |
|
| 559 |
return Max(source, selector, CancellationToken.None); |
| 560 |
} |
| 561 |
|
| 562 |
public static Task<long?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector) |
| 563 |
{ |
| 564 |
if (source == null) |
| 565 |
throw new ArgumentNullException("source"); |
| 566 |
if (selector == null) |
| 567 |
throw new ArgumentNullException("selector"); |
| 568 |
|
| 569 |
return Max(source, selector, CancellationToken.None); |
| 570 |
} |
| 571 |
|
| 572 |
public static Task<double?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector) |
| 573 |
{ |
| 574 |
if (source == null) |
| 575 |
throw new ArgumentNullException("source"); |
| 576 |
if (selector == null) |
| 577 |
throw new ArgumentNullException("selector"); |
| 578 |
|
| 579 |
return Max(source, selector, CancellationToken.None); |
| 580 |
} |
| 581 |
|
| 582 |
public static Task<float?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector) |
| 583 |
{ |
| 584 |
if (source == null) |
| 585 |
throw new ArgumentNullException("source"); |
| 586 |
if (selector == null) |
| 587 |
throw new ArgumentNullException("selector"); |
| 588 |
|
| 589 |
return Max(source, selector, CancellationToken.None); |
| 590 |
} |
| 591 |
|
| 592 |
public static Task<decimal?> Max<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal?> selector) |
| 593 |
{ |
| 594 |
if (source == null) |
| 595 |
throw new ArgumentNullException("source"); |
| 596 |
if (selector == null) |
| 597 |
throw new ArgumentNullException("selector"); |
| 598 |
|
| 599 |
return Max(source, selector, CancellationToken.None); |
| 600 |
} |
| 601 |
|
| 602 |
public static Task<TResult> Max<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector) |
| 603 |
{ |
| 604 |
if (source == null) |
| 605 |
throw new ArgumentNullException("source"); |
| 606 |
if (selector == null) |
| 607 |
throw new ArgumentNullException("selector"); |
| 608 |
|
| 609 |
return Max(source, selector, CancellationToken.None); |
| 610 |
} |
| 611 |
|
| 612 |
public static Task<int> Min(this IAsyncEnumerable<int> source) |
| 613 |
{ |
| 614 |
if (source == null) |
| 615 |
throw new ArgumentNullException("source"); |
| 616 |
|
| 617 |
return Min(source, CancellationToken.None); |
| 618 |
} |
| 619 |
|
| 620 |
public static Task<long> Min(this IAsyncEnumerable<long> source) |
| 621 |
{ |
| 622 |
if (source == null) |
| 623 |
throw new ArgumentNullException("source"); |
| 624 |
|
| 625 |
return Min(source, CancellationToken.None); |
| 626 |
} |
| 627 |
|
| 628 |
public static Task<double> Min(this IAsyncEnumerable<double> source) |
| 629 |
{ |
| 630 |
if (source == null) |
| 631 |
throw new ArgumentNullException("source"); |
| 632 |
|
| 633 |
return Min(source, CancellationToken.None); |
| 634 |
} |
| 635 |
|
| 636 |
public static Task<float> Min(this IAsyncEnumerable<float> source) |
| 637 |
{ |
| 638 |
if (source == null) |
| 639 |
throw new ArgumentNullException("source"); |
| 640 |
|
| 641 |
return Min(source, CancellationToken.None); |
| 642 |
} |
| 643 |
|
| 644 |
public static Task<decimal> Min(this IAsyncEnumerable<decimal> source) |
| 645 |
{ |
| 646 |
if (source == null) |
| 647 |
throw new ArgumentNullException("source"); |
| 648 |
|
| 649 |
return Min(source, CancellationToken.None); |
| 650 |
} |
| 651 |
|
| 652 |
public static Task<int?> Min(this IAsyncEnumerable<int?> source) |
| 653 |
{ |
| 654 |
if (source == null) |
| 655 |
throw new ArgumentNullException("source"); |
| 656 |
|
| 657 |
return Min(source, CancellationToken.None); |
| 658 |
} |
| 659 |
|
| 660 |
public static Task<long?> Min(this IAsyncEnumerable<long?> source) |
| 661 |
{ |
| 662 |
if (source == null) |
| 663 |
throw new ArgumentNullException("source"); |
| 664 |
|
| 665 |
return Min(source, CancellationToken.None); |
| 666 |
} |
| 667 |
|
| 668 |
public static Task<double?> Min(this IAsyncEnumerable<double?> source) |
| 669 |
{ |
| 670 |
if (source == null) |
| 671 |
throw new ArgumentNullException("source"); |
| 672 |
|
| 673 |
return Min(source, CancellationToken.None); |
| 674 |
} |
| 675 |
|
| 676 |
public static Task<float?> Min(this IAsyncEnumerable<float?> source) |
| 677 |
{ |
| 678 |
if (source == null) |
| 679 |
throw new ArgumentNullException("source"); |
| 680 |
|
| 681 |
return Min(source, CancellationToken.None); |
| 682 |
} |
| 683 |
|
| 684 |
public static Task<decimal?> Min(this IAsyncEnumerable<decimal?> source) |
| 685 |
{ |
| 686 |
if (source == null) |
| 687 |
throw new ArgumentNullException("source"); |
| 688 |
|
| 689 |
return Min(source, CancellationToken.None); |
| 690 |
} |
| 691 |
|
| 692 |
public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source) |
| 693 |
{ |
| 694 |
if (source == null) |
| 695 |
throw new ArgumentNullException("source"); |
| 696 |
|
| 697 |
return Min(source, CancellationToken.None); |
| 698 |
} |
| 699 |
|
| 700 |
public static Task<int> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int> selector) |
| 701 |
{ |
| 702 |
if (source == null) |
| 703 |
throw new ArgumentNullException("source"); |
| 704 |
if (selector == null) |
| 705 |
throw new ArgumentNullException("selector"); |
| 706 |
|
| 707 |
return Min(source, selector, CancellationToken.None); |
| 708 |
} |
| 709 |
|
| 710 |
public static Task<long> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long> selector) |
| 711 |
{ |
| 712 |
if (source == null) |
| 713 |
throw new ArgumentNullException("source"); |
| 714 |
if (selector == null) |
| 715 |
throw new ArgumentNullException("selector"); |
| 716 |
|
| 717 |
return Min(source, selector, CancellationToken.None); |
| 718 |
} |
| 719 |
|
| 720 |
public static Task<double> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double> selector) |
| 721 |
{ |
| 722 |
if (source == null) |
| 723 |
throw new ArgumentNullException("source"); |
| 724 |
if (selector == null) |
| 725 |
throw new ArgumentNullException("selector"); |
| 726 |
|
| 727 |
return Min(source, selector, CancellationToken.None); |
| 728 |
} |
| 729 |
|
| 730 |
public static Task<float> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float> selector) |
| 731 |
{ |
| 732 |
if (source == null) |
| 733 |
throw new ArgumentNullException("source"); |
| 734 |
if (selector == null) |
| 735 |
throw new ArgumentNullException("selector"); |
| 736 |
|
| 737 |
return Min(source, selector, CancellationToken.None); |
| 738 |
} |
| 739 |
|
| 740 |
public static Task<decimal> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, decimal> selector) |
| 741 |
{ |
| 742 |
if (source == null) |
| 743 |
throw new ArgumentNullException("source"); |
| 744 |
if (selector == null) |
| 745 |
throw new ArgumentNullException("selector"); |
| 746 |
|
| 747 |
return Min(source, selector, CancellationToken.None); |
| 748 |
} |
| 749 |
|
| 750 |
public static Task<int?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, int?> selector) |
| 751 |
{ |
| 752 |
if (source == null) |
| 753 |
throw new ArgumentNullException("source"); |
| 754 |
if (selector == null) |
| 755 |
throw new ArgumentNullException("selector"); |
| 756 |
|
| 757 |
return Min(source, selector, CancellationToken.None); |
| 758 |
} |
| 759 |
|
| 760 |
public static Task<long?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long?> selector) |
| 761 |
{ |
| 762 |
if (source == null) |
| 763 |
throw new ArgumentNullException("source"); |
| 764 |
if (selector == null) |
| 765 |
throw new ArgumentNullException("selector"); |
| 766 |
|
| 767 |
return Min(source, selector, CancellationToken.None); |
| 768 |
} |
| 769 |
|
| 770 |
public static Task<double?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, double?> selector) |
| 771 |
{ |
| 772 |
if (source == null) |
| 773 |
throw new ArgumentNullException("source"); |
| 774 |
if (selector == null) |
| 775 |
throw new ArgumentNullException("selector"); |
| 776 |
|
| 777 |
return Min(source, selector, CancellationToken.None); |
| 778 |
} |
| 779 |
|
| 780 |
public static Task<float?> Min<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, float?> selector) |
| 781 |
{ |
| 782 |
if (source == null) |
| 783 |
throw new ArgumentNullException("source"); |
| 784 |
if (selector == null) |
| 785 |
throw new ArgumentNullException("selector"); |
| 786 |
|
| 787 |
return Min(source, selector, CancellationToken.None); |
| 788 |
} |
| 789 |
|
| 790 |
public static Task<bool> SequenceEqual<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer) |
| 791 |
{ |
| 792 |
if (first == null) |
| 793 |
throw new ArgumentNullException("first"); |
| 794 |
if (second == null) |
| 795 |
throw new ArgumentNullException("second"); |
| 796 |
if (comparer == null) |
| 797 |
throw new ArgumentNullException("comparer"); |
| 798 |
|
| 799 |
return SequenceEqual(first, second, comparer, CancellationToken.None); |
| 800 |
} |
| 801 |
|
| 802 |
public static Task<bool> SequenceEqual<TSource>(this IAsyncEnumerable<TSource> first, IAsyncEnumerable<TSource> second) |
| 803 |
{ |
| 804 |
if (first == null) |
| 805 |
throw new ArgumentNullException("first"); |
| 806 |
if (second == null) |
| 807 |
throw new ArgumentNullException("second"); |
| 808 |
|
| 809 |
return SequenceEqual(first, second, CancellationToken.None); |
| 810 |
} |
| 811 |
|
| 812 |
public static Task<TResult> Aggregate<TSource, TAccumulate, TResult>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector) |
| 813 |
{ |
| 814 |
if (source == null) |
| 815 |
throw new ArgumentNullException("source"); |
| 816 |
if (accumulator == null) |
| 817 |
throw new ArgumentNullException("accumulator"); |
| 818 |
if (resultSelector == null) |
| 819 |
throw new ArgumentNullException("resultSelector"); |
| 820 |
|
| 821 |
return Aggregate(source, seed, accumulator, resultSelector, CancellationToken.None); |
| 822 |
} |
| 823 |
|
| 824 |
public static Task<TAccumulate> Aggregate<TSource, TAccumulate>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator) |
| 825 |
{ |
| 826 |
if (source == null) |
| 827 |
throw new ArgumentNullException("source"); |
| 828 |
if (accumulator == null) |
| 829 |
throw new ArgumentNullException("accumulator"); |
| 830 |
|
| 831 |
return Aggregate(source, seed, accumulator, CancellationToken.None); |
| 832 |
} |
| 833 |
|
| 834 |
public static Task<TSource> Aggregate<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, TSource, TSource> accumulator) |
| 835 |
{ |
| 836 |
if (source == null) |
| 837 |
throw new ArgumentNullException("source"); |
| 838 |
if (accumulator == null) |
| 839 |
throw new ArgumentNullException("accumulator"); |
| 840 |
|
| 841 |
return Aggregate(source, accumulator, CancellationToken.None); |
| 842 |
} |
| 843 |
|
| 844 |
public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source) |
| 845 |
{ |
| 846 |
if (source == null) |
| 847 |
throw new ArgumentNullException("source"); |
| 848 |
|
| 849 |
return Count(source, CancellationToken.None); |
| 850 |
} |
| 851 |
|
| 852 |
public static Task<int> Count<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 853 |
{ |
| 854 |
if (source == null) |
| 855 |
throw new ArgumentNullException("source"); |
| 856 |
if (predicate == null) |
| 857 |
throw new ArgumentNullException("predicate"); |
| 858 |
|
| 859 |
return Count(source, predicate, CancellationToken.None); |
| 860 |
} |
| 861 |
|
| 862 |
public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source) |
| 863 |
{ |
| 864 |
if (source == null) |
| 865 |
throw new ArgumentNullException("source"); |
| 866 |
|
| 867 |
return LongCount(source, CancellationToken.None); |
| 868 |
} |
| 869 |
|
| 870 |
public static Task<long> LongCount<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 871 |
{ |
| 872 |
if (source == null) |
| 873 |
throw new ArgumentNullException("source"); |
| 874 |
if (predicate == null) |
| 875 |
throw new ArgumentNullException("predicate"); |
| 876 |
|
| 877 |
return LongCount(source, predicate, CancellationToken.None); |
| 878 |
} |
| 879 |
|
| 880 |
public static Task<bool> All<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 881 |
{ |
| 882 |
if (source == null) |
| 883 |
throw new ArgumentNullException("source"); |
| 884 |
if (predicate == null) |
| 885 |
throw new ArgumentNullException("predicate"); |
| 886 |
|
| 887 |
return All(source, predicate, CancellationToken.None); |
| 888 |
} |
| 889 |
|
| 890 |
public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 891 |
{ |
| 892 |
if (source == null) |
| 893 |
throw new ArgumentNullException("source"); |
| 894 |
if (predicate == null) |
| 895 |
throw new ArgumentNullException("predicate"); |
| 896 |
|
| 897 |
return Any(source, predicate, CancellationToken.None); |
| 898 |
} |
| 899 |
|
| 900 |
public static Task<bool> Any<TSource>(this IAsyncEnumerable<TSource> source) |
| 901 |
{ |
| 902 |
if (source == null) |
| 903 |
throw new ArgumentNullException("source"); |
| 904 |
|
| 905 |
return Any(source, CancellationToken.None); |
| 906 |
} |
| 907 |
|
| 908 |
public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer) |
| 909 |
{ |
| 910 |
if (source == null) |
| 911 |
throw new ArgumentNullException("source"); |
| 912 |
if (comparer == null) |
| 913 |
throw new ArgumentNullException("comparer"); |
| 914 |
|
| 915 |
return Contains(source, value, comparer, CancellationToken.None); |
| 916 |
} |
| 917 |
|
| 918 |
public static Task<bool> Contains<TSource>(this IAsyncEnumerable<TSource> source, TSource value) |
| 919 |
{ |
| 920 |
if (source == null) |
| 921 |
throw new ArgumentNullException("source"); |
| 922 |
|
| 923 |
return Contains(source, value, CancellationToken.None); |
| 924 |
} |
| 925 |
|
| 926 |
public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source) |
| 927 |
{ |
| 928 |
if (source == null) |
| 929 |
throw new ArgumentNullException("source"); |
| 930 |
|
| 931 |
return First(source, CancellationToken.None); |
| 932 |
} |
| 933 |
|
| 934 |
public static Task<TSource> First<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 935 |
{ |
| 936 |
if (source == null) |
| 937 |
throw new ArgumentNullException("source"); |
| 938 |
if (predicate == null) |
| 939 |
throw new ArgumentNullException("predicate"); |
| 940 |
|
| 941 |
return First(source, predicate, CancellationToken.None); |
| 942 |
} |
| 943 |
|
| 944 |
public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source) |
| 945 |
{ |
| 946 |
if (source == null) |
| 947 |
throw new ArgumentNullException("source"); |
| 948 |
|
| 949 |
return FirstOrDefault(source, CancellationToken.None); |
| 950 |
} |
| 951 |
|
| 952 |
public static Task<TSource> FirstOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 953 |
{ |
| 954 |
if (source == null) |
| 955 |
throw new ArgumentNullException("source"); |
| 956 |
if (predicate == null) |
| 957 |
throw new ArgumentNullException("predicate"); |
| 958 |
|
| 959 |
return FirstOrDefault(source, predicate, CancellationToken.None); |
| 960 |
} |
| 961 |
|
| 962 |
public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source) |
| 963 |
{ |
| 964 |
if (source == null) |
| 965 |
throw new ArgumentNullException("source"); |
| 966 |
|
| 967 |
return Last(source, CancellationToken.None); |
| 968 |
} |
| 969 |
|
| 970 |
public static Task<TSource> Last<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 971 |
{ |
| 972 |
if (source == null) |
| 973 |
throw new ArgumentNullException("source"); |
| 974 |
if (predicate == null) |
| 975 |
throw new ArgumentNullException("predicate"); |
| 976 |
|
| 977 |
return Last(source, predicate, CancellationToken.None); |
| 978 |
} |
| 979 |
|
| 980 |
public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source) |
| 981 |
{ |
| 982 |
if (source == null) |
| 983 |
throw new ArgumentNullException("source"); |
| 984 |
|
| 985 |
return LastOrDefault(source, CancellationToken.None); |
| 986 |
} |
| 987 |
|
| 988 |
public static Task<TSource> LastOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 989 |
{ |
| 990 |
if (source == null) |
| 991 |
throw new ArgumentNullException("source"); |
| 992 |
if (predicate == null) |
| 993 |
throw new ArgumentNullException("predicate"); |
| 994 |
|
| 995 |
return LastOrDefault(source, predicate, CancellationToken.None); |
| 996 |
} |
| 997 |
|
| 998 |
public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source) |
| 999 |
{ |
| 1000 |
if (source == null) |
| 1001 |
throw new ArgumentNullException("source"); |
| 1002 |
|
| 1003 |
return Single(source, CancellationToken.None); |
| 1004 |
} |
| 1005 |
|
| 1006 |
public static Task<TSource> Single<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 1007 |
{ |
| 1008 |
if (source == null) |
| 1009 |
throw new ArgumentNullException("source"); |
| 1010 |
if (predicate == null) |
| 1011 |
throw new ArgumentNullException("predicate"); |
| 1012 |
|
| 1013 |
return Single(source, predicate, CancellationToken.None); |
| 1014 |
} |
| 1015 |
|
| 1016 |
public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source) |
| 1017 |
{ |
| 1018 |
if (source == null) |
| 1019 |
throw new ArgumentNullException("source"); |
| 1020 |
|
| 1021 |
return SingleOrDefault(source, CancellationToken.None); |
| 1022 |
} |
| 1023 |
|
| 1024 |
public static Task<TSource> SingleOrDefault<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate) |
| 1025 |
{ |
| 1026 |
if (source == null) |
| 1027 |
throw new ArgumentNullException("source"); |
| 1028 |
if (predicate == null) |
| 1029 |
throw new ArgumentNullException("predicate"); |
| 1030 |
|
| 1031 |
return SingleOrDefault(source, predicate, CancellationToken.None); |
| 1032 |
} |
| 1033 |
|
| 1034 |
public static Task<TSource> ElementAt<TSource>(this IAsyncEnumerable<TSource> source, int index) |
| 1035 |
{ |
| 1036 |
if (source == null) |
| 1037 |
throw new ArgumentNullException("source"); |
| 1038 |
|
| 1039 |
return ElementAt(source, index, CancellationToken.None); |
| 1040 |
} |
| 1041 |
|
| 1042 |
public static Task<TSource> ElementAtOrDefault<TSource>(this IAsyncEnumerable<TSource> source, int index) |
| 1043 |
{ |
| 1044 |
if (source == null) |
| 1045 |
throw new ArgumentNullException("source"); |
| 1046 |
|
| 1047 |
return ElementAtOrDefault(source, index, CancellationToken.None); |
| 1048 |
} |
| 1049 |
|
| 1050 |
public static Task<TSource[]> ToArray<TSource>(this IAsyncEnumerable<TSource> source) |
| 1051 |
{ |
| 1052 |
if (source == null) |
| 1053 |
throw new ArgumentNullException("source"); |
| 1054 |
|
| 1055 |
return ToArray(source, CancellationToken.None); |
| 1056 |
} |
| 1057 |
|
| 1058 |
public static Task<List<TSource>> ToList<TSource>(this IAsyncEnumerable<TSource> source) |
| 1059 |
{ |
| 1060 |
if (source == null) |
| 1061 |
throw new ArgumentNullException("source"); |
| 1062 |
|
| 1063 |
return ToList(source, CancellationToken.None); |
| 1064 |
} |
| 1065 |
|
| 1066 |
public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer) |
| 1067 |
{ |
| 1068 |
if (source == null) |
| 1069 |
throw new ArgumentNullException("source"); |
| 1070 |
if (keySelector == null) |
| 1071 |
throw new ArgumentNullException("keySelector"); |
| 1072 |
if (elementSelector == null) |
| 1073 |
throw new ArgumentNullException("elementSelector"); |
| 1074 |
if (comparer == null) |
| 1075 |
throw new ArgumentNullException("comparer"); |
| 1076 |
|
| 1077 |
return ToDictionary(source, keySelector, elementSelector, comparer, CancellationToken.None); |
| 1078 |
} |
| 1079 |
|
| 1080 |
public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) |
| 1081 |
{ |
| 1082 |
if (source == null) |
| 1083 |
throw new ArgumentNullException("source"); |
| 1084 |
if (keySelector == null) |
| 1085 |
throw new ArgumentNullException("keySelector"); |
| 1086 |
if (elementSelector == null) |
| 1087 |
throw new ArgumentNullException("elementSelector"); |
| 1088 |
|
| 1089 |
return ToDictionary(source, keySelector, elementSelector, CancellationToken.None); |
| 1090 |
} |
| 1091 |
|
| 1092 |
public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) |
| 1093 |
{ |
| 1094 |
if (source == null) |
| 1095 |
throw new ArgumentNullException("source"); |
| 1096 |
if (keySelector == null) |
| 1097 |
throw new ArgumentNullException("keySelector"); |
| 1098 |
if (comparer == null) |
| 1099 |
throw new ArgumentNullException("comparer"); |
| 1100 |
|
| 1101 |
return ToDictionary(source, keySelector, comparer, CancellationToken.None); |
| 1102 |
} |
| 1103 |
|
| 1104 |
public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector) |
| 1105 |
{ |
| 1106 |
if (source == null) |
| 1107 |
throw new ArgumentNullException("source"); |
| 1108 |
if (keySelector == null) |
| 1109 |
throw new ArgumentNullException("keySelector"); |
| 1110 |
|
| 1111 |
return ToDictionary(source, keySelector, CancellationToken.None); |
| 1112 |
} |
| 1113 |
|
| 1114 |
public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer) |
| 1115 |
{ |
| 1116 |
if (source == null) |
| 1117 |
throw new ArgumentNullException("source"); |
| 1118 |
if (keySelector == null) |
| 1119 |
throw new ArgumentNullException("keySelector"); |
| 1120 |
if (elementSelector == null) |
| 1121 |
throw new ArgumentNullException("elementSelector"); |
| 1122 |
if (comparer == null) |
| 1123 |
throw new ArgumentNullException("comparer"); |
| 1124 |
|
| 1125 |
return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None); |
| 1126 |
} |
| 1127 |
|
| 1128 |
public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) |
| 1129 |
{ |
| 1130 |
if (source == null) |
| 1131 |
throw new ArgumentNullException("source"); |
| 1132 |
if (keySelector == null) |
| 1133 |
throw new ArgumentNullException("keySelector"); |
| 1134 |
if (elementSelector == null) |
| 1135 |
throw new ArgumentNullException("elementSelector"); |
| 1136 |
|
| 1137 |
return ToLookup(source, keySelector, elementSelector, CancellationToken.None); |
| 1138 |
} |
| 1139 |
|
| 1140 |
public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) |
| 1141 |
{ |
| 1142 |
if (source == null) |
| 1143 |
throw new ArgumentNullException("source"); |
| 1144 |
if (keySelector == null) |
| 1145 |
throw new ArgumentNullException("keySelector"); |
| 1146 |
if (comparer == null) |
| 1147 |
throw new ArgumentNullException("comparer"); |
| 1148 |
|
| 1149 |
return ToLookup(source, keySelector, comparer, CancellationToken.None); |
| 1150 |
} |
| 1151 |
|
| 1152 |
public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector) |
| 1153 |
{ |
| 1154 |
if (source == null) |
| 1155 |
throw new ArgumentNullException("source"); |
| 1156 |
if (keySelector == null) |
| 1157 |
throw new ArgumentNullException("keySelector"); |
| 1158 |
|
| 1159 |
return ToLookup(source, keySelector, CancellationToken.None); |
| 1160 |
} |
| 1161 |
|
| 1162 |
public static Task<double> Average(this IAsyncEnumerable<int> source) |
| 1163 |
{ |
| 1164 |
if (source == null) |
| 1165 |
throw new ArgumentNullException("source"); |
| 1166 |
|
| 1167 |
return Average(source, CancellationToken.None); |
| 1168 |
} |
| 1169 |
|
| 1170 |
public static Task<double?> Average(this IAsyncEnumerable<int?> source) |
| 1171 |
{ |
| 1172 |
if (source == null) |
| 1173 |
throw new ArgumentNullException("source"); |
| 1174 |
|
| 1175 |
return Average(source, CancellationToken.None); |
| 1176 |
} |
| 1177 |
|
| 1178 |
public static Task<bool> IsEmpty<TSource>(this IAsyncEnumerable<TSource> source) |
| 1179 |
{ |
| 1180 |
if (source == null) |
| 1181 |
throw new ArgumentNullException("source"); |
| 1182 |
|
| 1183 |
return source.IsEmpty(CancellationToken.None); |
| 1184 |
} |
| 1185 |
|
| 1186 |
public static Task<TSource> Min<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer) |
| 1187 |
{ |
| 1188 |
if (source == null) |
| 1189 |
throw new ArgumentNullException("source"); |
| 1190 |
if (comparer == null) |
| 1191 |
throw new ArgumentNullException("comparer"); |
| 1192 |
|
| 1193 |
return source.Min(comparer, CancellationToken.None); |
| 1194 |
} |
| 1195 |
|
| 1196 |
public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector) |
| 1197 |
{ |
| 1198 |
if (source == null) |
| 1199 |
throw new ArgumentNullException("source"); |
| 1200 |
if (keySelector == null) |
| 1201 |
throw new ArgumentNullException("keySelector"); |
| 1202 |
|
| 1203 |
return source.MinBy(keySelector, CancellationToken.None); |
| 1204 |
} |
| 1205 |
|
| 1206 |
public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer) |
| 1207 |
{ |
| 1208 |
if (source == null) |
| 1209 |
throw new ArgumentNullException("source"); |
| 1210 |
if (keySelector == null) |
| 1211 |
throw new ArgumentNullException("keySelector"); |
| 1212 |
if (comparer == null) |
| 1213 |
throw new ArgumentNullException("comparer"); |
| 1214 |
|
| 1215 |
return source.MinBy(keySelector, comparer, CancellationToken.None); |
| 1216 |
} |
| 1217 |
|
| 1218 |
public static Task<TSource> Max<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource> comparer) |
| 1219 |
{ |
| 1220 |
if (source == null) |
| 1221 |
throw new ArgumentNullException("source"); |
| 1222 |
if (comparer == null) |
| 1223 |
throw new ArgumentNullException("comparer"); |
| 1224 |
|
| 1225 |
return source.Max(comparer, CancellationToken.None); |
| 1226 |
} |
| 1227 |
|
| 1228 |
public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector) |
| 1229 |
{ |
| 1230 |
if (source == null) |
| 1231 |
throw new ArgumentNullException("source"); |
| 1232 |
if (keySelector == null) |
| 1233 |
throw new ArgumentNullException("keySelector"); |
| 1234 |
|
| 1235 |
return source.MaxBy(keySelector, CancellationToken.None); |
| 1236 |
} |
| 1237 |
|
| 1238 |
public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer) |
| 1239 |
{ |
| 1240 |
if (source == null) |
| 1241 |
throw new ArgumentNullException("source"); |
| 1242 |
if (keySelector == null) |
| 1243 |
throw new ArgumentNullException("keySelector"); |
| 1244 |
if (comparer == null) |
| 1245 |
throw new ArgumentNullException("comparer"); |
| 1246 |
|
| 1247 |
return source.MaxBy(keySelector, comparer, CancellationToken.None); |
| 1248 |
} |
| 1249 |
} |
| 1250 |
} |