1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Reactive.Concurrency;
namespace System.Reactive.Linq
{
public static partial class Observable
{
#region + AsObservable +
/// <summary>
/// Hides the identity of an observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">An observable sequence whose identity to hide.</param>
/// <returns>An observable sequence that hides the identity of the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public static IObservable<TSource> AsObservable<TSource>(this IObservable<TSource> source)
{
if (source == null)
throw new ArgumentNullException("source");
return s_impl.AsObservable<TSource>(source);
}
#endregion
#region + Buffer +
/// <summary>
/// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on element count information.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
/// <param name="source">Source sequence to produce buffers over.</param>
/// <param name="count">Length of each buffer.</param>
/// <returns>An observable sequence of buffers.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than or equal to zero.</exception>
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, int count)
{
if (source == null)
throw new ArgumentNullException("source");
if (count <= 0)
throw new ArgumentOutOfRangeException("count");
return s_impl.Buffer<TSource>(source, count);
}
/// <summary>
/// Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
/// <param name="source">Source sequence to produce buffers over.</param>
/// <param name="count">Length of each buffer.</param>
/// <param name="skip">Number of elements to skip between creation of consecutive buffers.</param>
/// <returns>An observable sequence of buffers.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> or <paramref name="skip"/> is less than or equal to zero.</exception>
public static IObservable<IList<TSource>> Buffer<TSource>(this IObservable<TSource> source, int count, int skip)
{
if (source == null)
throw new ArgumentNullException("source");
if (count <= 0)
throw new ArgumentOutOfRangeException("count");
if (skip <= 0)
throw new ArgumentOutOfRangeException("skip");
return s_impl.Buffer<TSource>(source, count, skip);
}
#endregion
#region + Dematerialize +
/// <summary>
/// Dematerializes the explicit notification values of an observable sequence as implicit notifications.
/// </summary>
/// <typeparam name="TSource">The type of the elements materialized in the source sequence notification objects.</typeparam>
/// <param name="source">An observable sequence containing explicit notification values which have to be turned into implicit notifications.</param>
/// <returns>An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public static IObservable<TSource> Dematerialize<TSource>(this IObservable<Notification<TSource>> source)
{
if (source == null)
throw new ArgumentNullException("source");
return s_impl.Dematerialize<TSource>(source);
}
#endregion
#region + DistinctUntilChanged +
/// <summary>
/// Returns an observable sequence that contains only distinct contiguous elements.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
/// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public static IObservable<TSource> DistinctUntilChanged<TSource>(this IObservable<TSource> source)
{
if (source == null)
throw new ArgumentNullException("source");
return s_impl.DistinctUntilChanged<TSource>(source);
}
/// <summary>
/// Returns an observable sequence that contains only distinct contiguous elements according to the comparer.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
/// <param name="comparer">Equality comparer for source elements.</param>
/// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="comparer"/> is null.</exception>
public static IObservable<TSource> DistinctUntilChanged<TSource>(this IObservable<TSource> source, IEqualityComparer<TSource> comparer)
{
if (source == null)
throw new ArgumentNullException("source");
if (comparer == null)
throw new ArgumentNullException("comparer");
return s_impl.DistinctUntilChanged<TSource>(source, comparer);
}
/// <summary>
/// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
/// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
/// <param name="keySelector">A function to compute the comparison key for each element.</param>
/// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> is null.</exception>
public static IObservable<TSource> DistinctUntilChanged<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector)
{
if (source == null)
throw new ArgumentNullException("source");
if (keySelector == null)
throw new ArgumentNullException("keySelector");
return s_impl.DistinctUntilChanged<TSource, TKey>(source, keySelector);
}
/// <summary>
/// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
/// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
/// <param name="keySelector">A function to compute the comparison key for each element.</param>
/// <param name="comparer">Equality comparer for computed key values.</param>
/// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="comparer"/> is null.</exception>
public static IObservable<TSource> DistinctUntilChanged<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
{
if (source == null)
throw new ArgumentNullException("source");
if (keySelector == null)
throw new ArgumentNullException("keySelector");
if (comparer == null)
throw new ArgumentNullException("comparer");
return s_impl.DistinctUntilChanged<TSource, TKey>(source, keySelector, comparer);
}
#endregion
#region + Do +
/// <summary>
/// Invokes an action for each element in the observable sequence, and propagates all observer messages through the result sequence.
/// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
/// <returns>The source sequence with the side-effecting behavior applied.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> is null.</exception>
public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext)
{
if (source == null)
throw new ArgumentNullException("source");
if (onNext == null)
throw new ArgumentNullException("onNext");
return s_impl.Do<TSource>(source, onNext);
}
/// <summary>
/// Invokes an action for each element in the observable sequence and invokes an action upon graceful termination of the observable sequence.
/// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
/// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
/// <returns>The source sequence with the side-effecting behavior applied.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onCompleted"/> is null.</exception>
public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action onCompleted)
{
if (source == null)
throw new ArgumentNullException("source");
if (onNext == null)
throw new ArgumentNullException("onNext");
if (onCompleted == null)
throw new ArgumentNullException("onCompleted");
return s_impl.Do<TSource>(source, onNext, onCompleted);
}
/// <summary>
/// Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence.
/// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
/// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
/// <returns>The source sequence with the side-effecting behavior applied.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onError"/> is null.</exception>
public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError)
{
if (source == null)
throw new ArgumentNullException("source");
if (onNext == null)
throw new ArgumentNullException("onNext");
if (onError == null)
throw new ArgumentNullException("onError");
return s_impl.Do<TSource>(source, onNext, onError);
}
/// <summary>
/// Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
/// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
/// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
/// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
/// <returns>The source sequence with the side-effecting behavior applied.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onError"/> or <paramref name="onCompleted"/> is null.</exception>
public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
{
if (source == null)
throw new ArgumentNullException("source");
if (onNext == null)
throw new ArgumentNullException("onNext");
if (onError == null)
throw new ArgumentNullException("onError");
if (onCompleted == null)
throw new ArgumentNullException("onCompleted");
return s_impl.Do<TSource>(source, onNext, onError, onCompleted);
}
/// <summary>
/// Invokes the observer's methods for each message in the source sequence.
/// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="observer">Observer whose methods to invoke as part of the source sequence's observation.</param>
/// <returns>The source sequence with the side-effecting behavior applied.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="observer"/> is null.</exception>
public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, IObserver<TSource> observer)
{
if (source == null)
throw new ArgumentNullException("source");
if (observer == null)
throw new ArgumentNullException("observer");
return s_impl.Do<TSource>(source, observer);
}
#endregion
#region + Finally +
/// <summary>
/// Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="finallyAction">Action to invoke after the source observable sequence terminates.</param>
/// <returns>Source sequence with the action-invoking termination behavior applied.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="finallyAction"/> is null.</exception>
public static IObservable<TSource> Finally<TSource>(this IObservable<TSource> source, Action finallyAction)
{
if (source == null)
throw new ArgumentNullException("source");
if (finallyAction == null)
throw new ArgumentNullException("finallyAction");
return s_impl.Finally<TSource>(source, finallyAction);
}
#endregion
#region + IgnoreElements +
/// <summary>
/// Ignores all elements in an observable sequence leaving only the termination messages.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <returns>An empty observable sequence that signals termination, successful or exceptional, of the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public static IObservable<TSource> IgnoreElements<TSource>(this IObservable<TSource> source)
{
if (source == null)
throw new ArgumentNullException("source");
return s_impl.IgnoreElements<TSource>(source);
}
#endregion
#region + Materialize +
/// <summary>
/// Materializes the implicit notifications of an observable sequence as explicit notification values.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">An observable sequence to get notification values for.</param>
/// <returns>An observable sequence containing the materialized notification values from the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public static IObservable<Notification<TSource>> Materialize<TSource>(this IObservable<TSource> source)
{
if (source == null)
throw new ArgumentNullException("source");
return s_impl.Materialize<TSource>(source);
}
#endregion
#region + Repeat +
/// <summary>
/// Repeats the observable sequence indefinitely.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Observable sequence to repeat.</param>
/// <returns>The observable sequence producing the elements of the given sequence repeatedly and sequentially.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public static IObservable<TSource> Repeat<TSource>(this IObservable<TSource> source)
{
if (source == null)
throw new ArgumentNullException("source");
return s_impl.Repeat<TSource>(source);
}
/// <summary>
/// Repeats the observable sequence a specified number of times.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Observable sequence to repeat.</param>
/// <param name="repeatCount">Number of times to repeat the sequence.</param>
/// <returns>The observable sequence producing the elements of the given sequence repeatedly.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="repeatCount"/> is less than zero.</exception>
public static IObservable<TSource> Repeat<TSource>(this IObservable<TSource> source, int repeatCount)
{
if (source == null)
throw new ArgumentNullException("source");
if (repeatCount < 0)
throw new ArgumentOutOfRangeException("repeatCount");
return s_impl.Repeat<TSource>(source, repeatCount);
}
#endregion
#region + Retry +
/// <summary>
/// Repeats the source observable sequence until it successfully terminates.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
/// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public static IObservable<TSource> Retry<TSource>(this IObservable<TSource> source)
{
if (source == null)
throw new ArgumentNullException("source");
return s_impl.Retry<TSource>(source);
}
/// <summary>
/// Repeats the source observable sequence the specified number of times or until it successfully terminates.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
/// <param name="retryCount">Number of times to repeat the sequence.</param>
/// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="retryCount"/> is less than zero.</exception>
public static IObservable<TSource> Retry<TSource>(this IObservable<TSource> source, int retryCount)
{
if (source == null)
throw new ArgumentNullException("source");
if (retryCount < 0)
throw new ArgumentOutOfRangeException("retryCount");
return s_impl.Retry<TSource>(source, retryCount);
}
#endregion
#region + Scan +
/// <summary>
/// Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
/// For aggregation behavior with no intermediate results, see <see cref="Observable.Aggregate<TSource, Accumulate>"/>.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
/// <param name="source">An observable sequence to accumulate over.</param>
/// <param name="seed">The initial accumulator value.</param>
/// <param name="accumulator">An accumulator function to be invoked on each element.</param>
/// <returns>An observable sequence containing the accumulated values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="accumulator"/> is null.</exception>
public static IObservable<TAccumulate> Scan<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
{
if (source == null)
throw new ArgumentNullException("source");
if (accumulator == null)
throw new ArgumentNullException("accumulator");
return s_impl.Scan<TSource, TAccumulate>(source, seed, accumulator);
}
/// <summary>
/// Applies an accumulator function over an observable sequence and returns each intermediate result.
/// For aggregation behavior with no intermediate results, see <see cref="Observable.Aggregate<TSource>"/>.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
/// <param name="source">An observable sequence to accumulate over.</param>
/// <param name="accumulator">An accumulator function to be invoked on each element.</param>
/// <returns>An observable sequence containing the accumulated values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="accumulator"/> is null.</exception>
public static IObservable<TSource> Scan<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)
{
if (source == null)
throw new ArgumentNullException("source");
if (accumulator == null)
throw new ArgumentNullException("accumulator");
return s_impl.Scan<TSource>(source, accumulator);
}
#endregion
#region + SkipLast +
/// <summary>
/// Bypasses a specified number of elements at the end of an observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="count">Number of elements to bypass at the end of the source sequence.</param>
/// <returns>An observable sequence containing the source sequence elements except for the bypassed ones at the end.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than zero.</exception>
/// <remarks>
/// This operator accumulates a queue with a length enough to store the first <paramref name="count"/> elements. As more elements are
/// received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
/// </remarks>
public static IObservable<TSource> SkipLast<TSource>(this IObservable<TSource> source, int count)
{
if (source == null)
throw new ArgumentNullException("source");
if (count < 0)
throw new ArgumentOutOfRangeException("count");
return s_impl.SkipLast<TSource>(source, count);
}
#endregion
#region + StartWith +
/// <summary>
/// Prepends a sequence of values to an observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence to prepend values to.</param>
/// <param name="values">Values to prepend to the specified sequence.</param>
/// <returns>The source sequence prepended with the specified values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="values"/> is null.</exception>
public static IObservable<TSource> StartWith<TSource>(this IObservable<TSource> source, params TSource[] values)
{
if (source == null)
throw new ArgumentNullException("source");
if (values == null)
throw new ArgumentNullException("values");
return s_impl.StartWith<TSource>(source, values);
}
/// <summary>
/// Prepends a sequence of values to an observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence to prepend values to.</param>
/// <param name="values">Values to prepend to the specified sequence.</param>
/// <returns>The source sequence prepended with the specified values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="values"/> is null.</exception>
public static IObservable<TSource> StartWith<TSource>(this IObservable<TSource> source, IEnumerable<TSource> values)
{
if (source == null)
throw new ArgumentNullException("source");
if (values == null)
throw new ArgumentNullException("values");
TSource[] valueArray = values as TSource[];
if (valueArray == null)
{
List<TSource> valueList = new List<TSource>(values);
valueArray = valueList.ToArray();
}
return s_impl.StartWith<TSource>(source, valueArray);
}
/// <summary>
/// Prepends a sequence of values to an observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence to prepend values to.</param>
/// <param name="scheduler">Scheduler to emit the prepended values on.</param>
/// <param name="values">Values to prepend to the specified sequence.</param>
/// <returns>The source sequence prepended with the specified values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="scheduler"/> or <paramref name="values"/> is null.</exception>
public static IObservable<TSource> StartWith<TSource>(this IObservable<TSource> source, IScheduler scheduler, params TSource[] values)
{
if (source == null)
throw new ArgumentNullException("source");
if (scheduler == null)
throw new ArgumentNullException("scheduler");
if (values == null)
throw new ArgumentNullException("values");
return s_impl.StartWith<TSource>(source, scheduler, values);
}
/// <summary>
/// Prepends a sequence of values to an observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence to prepend values to.</param>
/// <param name="scheduler">Scheduler to emit the prepended values on.</param>
/// <param name="values">Values to prepend to the specified sequence.</param>
/// <returns>The source sequence prepended with the specified values.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="scheduler"/> or <paramref name="values"/> is null.</exception>
public static IObservable<TSource> StartWith<TSource>(this IObservable<TSource> source, IScheduler scheduler, IEnumerable<TSource> values)
{
if (source == null)
throw new ArgumentNullException("source");
if (scheduler == null)
throw new ArgumentNullException("scheduler");
if (values == null)
throw new ArgumentNullException("values");
TSource[] valueArray = values as TSource[];
if (valueArray == null)
{
List<TSource> valueList = new List<TSource>(values);
valueArray = valueList.ToArray();
}
return s_impl.StartWith<TSource>(source, scheduler, valueArray);
}
#endregion
#region + TakeLast +
/// <summary>
/// Returns a specified number of contiguous elements from the end of an observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="count">Number of elements to take from the end of the source sequence.</param>
/// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than zero.</exception>
/// <remarks>
/// This operator accumulates a buffer with a length enough to store elements <paramref name="count"/> elements. Upon completion of
/// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
/// </remarks>
public static IObservable<TSource> TakeLast<TSource>(this IObservable<TSource> source, int count)
{
if (source == null)
throw new ArgumentNullException("source");
if (count < 0)
throw new ArgumentOutOfRangeException("count");
return s_impl.TakeLast<TSource>(source, count);
}
/// <summary>
/// Returns a specified number of contiguous elements from the end of an observable sequence, using the specified scheduler to drain the queue.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="count">Number of elements to take from the end of the source sequence.</param>
/// <param name="scheduler">Scheduler used to drain the queue upon completion of the source sequence.</param>
/// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="scheduler"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than zero.</exception>
/// <remarks>
/// This operator accumulates a buffer with a length enough to store elements <paramref name="count"/> elements. Upon completion of
/// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
/// </remarks>
public static IObservable<TSource> TakeLast<TSource>(this IObservable<TSource> source, int count, IScheduler scheduler)
{
if (source == null)
throw new ArgumentNullException("source");
if (count < 0)
throw new ArgumentOutOfRangeException("count");
if (scheduler == null)
throw new ArgumentNullException("scheduler");
return s_impl.TakeLast<TSource>(source, count, scheduler);
}
#endregion
#region + TakeLastBuffer +
/// <summary>
/// Returns a list with the specified number of contiguous elements from the end of an observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Source sequence.</param>
/// <param name="count">Number of elements to take from the end of the source sequence.</param>
/// <returns>An observable sequence containing a single list with the specified number of elements from the end of the source sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than zero.</exception>
/// <remarks>
/// This operator accumulates a buffer with a length enough to store <paramref name="count"/> elements. Upon completion of the
/// source sequence, this buffer is produced on the result sequence.
/// </remarks>
public static IObservable<IList<TSource>> TakeLastBuffer<TSource>(this IObservable<TSource> source, int count)
{
if (source == null)
throw new ArgumentNullException("source");
if (count < 0)
throw new ArgumentOutOfRangeException("count");
return s_impl.TakeLastBuffer<TSource>(source, count);
}
#endregion
#region + Window +
/// <summary>
/// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
/// <param name="source">Source sequence to produce windows over.</param>
/// <param name="count">Length of each window.</param>
/// <returns>An observable sequence of windows.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than or equal to zero.</exception>
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, int count)
{
if (source == null)
throw new ArgumentNullException("source");
if (count <= 0)
throw new ArgumentOutOfRangeException("count");
return s_impl.Window<TSource>(source, count);
}
/// <summary>
/// Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
/// <param name="source">Source sequence to produce windows over.</param>
/// <param name="count">Length of each window.</param>
/// <param name="skip">Number of elements to skip between creation of consecutive windows.</param>
/// <returns>An observable sequence of windows.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> or <paramref name="skip"/> is less than or equal to zero.</exception>
public static IObservable<IObservable<TSource>> Window<TSource>(this IObservable<TSource> source, int count, int skip)
{
if (source == null)
throw new ArgumentNullException("source");
if (count <= 0)
throw new ArgumentOutOfRangeException("count");
if (skip <= 0)
throw new ArgumentOutOfRangeException("skip");
return s_impl.Window<TSource>(source, count, skip);
}
#endregion
}
}
|