Debian Codegraph @

external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.Joins.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 using System.Collections.Generic;
4 using System.Reactive.Disposables;
5 using System.Reactive.Joins;
6
7 namespace System.Reactive.Linq
8 {
9 public static partial class Observable
10 {
11 #region And
12
13 /// <summary>
14 /// Creates a pattern that matches when both observable sequences have an available element.
15 /// </summary>
16 /// <typeparam name="TLeft">The type of the elements in the left sequence.</typeparam>
17 /// <typeparam name="TRight">The type of the elements in the right sequence.</typeparam>
18 /// <param name="left">Observable sequence to match with the right sequence.</param>
19 /// <param name="right">Observable sequence to match with the left sequence.</param>
20 /// <returns>Pattern object that matches when both observable sequences have an available element.</returns>
21 /// <exception cref="ArgumentNullException"><paramref name="left"/> or <paramref name="right"/> is null.</exception>
22 public static Pattern<TLeft, TRight> And<TLeft, TRight>(this IObservable<TLeft> left, IObservable<TRight> right)
23 {
24 if (left == null)
25 throw new ArgumentNullException("left");
26 if (right == null)
27 throw new ArgumentNullException("right");
28
29 return s_impl.And<TLeft, TRight>(left, right);
30 }
31
32 #endregion
33
34 #region Then
35
36 /// <summary>
37 /// Matches when the observable sequence has an available element and projects the element by invoking the selector function.
38 /// </summary>
39 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
40 /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
41 /// <param name="source">Observable sequence to apply the selector on.</param>
42 /// <param name="selector">Selector that will be invoked for elements in the source sequence.</param>
43 /// <returns>Plan that produces the projected results, to be fed (with other plans) to the When operator.</returns>
44 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
45 public static Plan<TResult> Then<TSource, TResult>(this IObservable<TSource> source, Func<TSource, TResult> selector)
46 {
47 if (source == null)
48 throw new ArgumentNullException("source");
49 if (selector == null)
50 throw new ArgumentNullException("selector");
51
52 return s_impl.Then<TSource, TResult>(source, selector);
53 }
54
55 #endregion
56
57 #region When
58
59 /// <summary>
60 /// Joins together the results from several patterns.
61 /// </summary>
62 /// <typeparam name="TResult">The type of the elements in the result sequence, obtained from the specified patterns.</typeparam>
63 /// <param name="plans">A series of plans created by use of the Then operator on patterns.</param>
64 /// <returns>An observable sequence with the results from matching several patterns.</returns>
65 /// <exception cref="ArgumentNullException"><paramref name="plans"/> is null.</exception>
66 public static IObservable<TResult> When<TResult>(params Plan<TResult>[] plans)
67 {
68 if (plans == null)
69 throw new ArgumentNullException("plans");
70
71 return s_impl.When<TResult>(plans);
72 }
73
74 /// <summary>
75 /// Joins together the results from several patterns.
76 /// </summary>
77 /// <typeparam name="TResult">The type of the elements in the result sequence, obtained from the specified patterns.</typeparam>
78 /// <param name="plans">A series of plans created by use of the Then operator on patterns.</param>
79 /// <returns>An observable sequence with the results form matching several patterns.</returns>
80 /// <exception cref="ArgumentNullException"><paramref name="plans"/> is null.</exception>
81 public static IObservable<TResult> When<TResult>(this IEnumerable<Plan<TResult>> plans)
82 {
83 if (plans == null)
84 throw new ArgumentNullException("plans");
85
86 return s_impl.When<TResult>(plans);
87 }
88
89 #endregion
90 }
91 }