| 1 |
/* |
| 2 |
* WARNING: Auto-generated file (11/21/2013 11:07:25 AM) |
| 3 |
* Run Rx's auto-homoiconizer tool to generate this file (in the HomoIcon directory). |
| 4 |
*/ |
| 5 |
|
| 6 |
#pragma warning disable 1591 |
| 7 |
|
| 8 |
#if !NO_EXPRESSIONS |
| 9 |
|
| 10 |
using System; |
| 11 |
using System.Reactive.Concurrency; |
| 12 |
using System.Collections.Generic; |
| 13 |
using System.Reactive.Joins; |
| 14 |
using System.Linq; |
| 15 |
using System.Linq.Expressions; |
| 16 |
using System.Reflection; |
| 17 |
using System.Threading; |
| 18 |
using System.Reactive; |
| 19 |
using System.Reactive.Subjects; |
| 20 |
#if !NO_TPL |
| 21 |
using System.Threading.Tasks; |
| 22 |
#endif |
| 23 |
#if !NO_REMOTING |
| 24 |
using System.Runtime.Remoting.Lifetime; |
| 25 |
#endif |
| 26 |
|
| 27 |
namespace System.Reactive.Linq |
| 28 |
{ |
| 29 |
public static partial class QbservableEx |
| 30 |
{ |
| 31 |
#if !STABLE |
| 32 |
/// <summary> |
| 33 |
/// Subscribes to each observable sequence returned by the iteratorMethod in sequence and produces a Unit value on the resulting sequence for each step of the iteration. |
| 34 |
/// </summary> |
| 35 |
/// <param name="provider">Query provider used to construct the IQbservable<T> data source.</param> |
| 36 |
/// <param name="iteratorMethod">Iterator method that drives the resulting observable sequence.</param> |
| 37 |
/// <returns>An observable sequence obtained by running the iterator and returning Unit values for each iteration step.</returns> |
| 38 |
/// <exception cref="T:System.ArgumentNullException"> |
| 39 |
/// <paramref name="iteratorMethod" /> is null.</exception> |
| 40 |
[Experimental] |
| 41 |
public static IQbservable<Unit> Create(this IQbservableProvider provider, Expression<Func<IEnumerable<IObservable<object>>>> iteratorMethod) |
| 42 |
{ |
| 43 |
if (provider == null) |
| 44 |
throw new ArgumentNullException("provider"); |
| 45 |
if (iteratorMethod == null) |
| 46 |
throw new ArgumentNullException("iteratorMethod"); |
| 47 |
|
| 48 |
return provider.CreateQuery<Unit>( |
| 49 |
Expression.Call( |
| 50 |
null, |
| 51 |
#if CRIPPLED_REFLECTION |
| 52 |
InfoOf(() => QbservableEx.Create(default(IQbservableProvider), default(Expression<Func<IEnumerable<IObservable<object>>>>))), |
| 53 |
#else |
| 54 |
(MethodInfo)MethodInfo.GetCurrentMethod(), |
| 55 |
#endif |
| 56 |
Expression.Constant(provider, typeof(IQbservableProvider)), |
| 57 |
iteratorMethod |
| 58 |
) |
| 59 |
); |
| 60 |
} |
| 61 |
#endif |
| 62 |
|
| 63 |
#if !STABLE |
| 64 |
/// <summary> |
| 65 |
/// Subscribes to each observable sequence returned by the iteratorMethod in sequence and returns the observable sequence of values sent to the observer given to the iteratorMethod. |
| 66 |
/// </summary> |
| 67 |
/// <param name="provider">Query provider used to construct the IQbservable<T> data source.</param> |
| 68 |
/// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam> |
| 69 |
/// <param name="iteratorMethod">Iterator method that produces elements in the resulting sequence by calling the given observer.</param> |
| 70 |
/// <returns>An observable sequence obtained by running the iterator and returning the elements that were sent to the observer.</returns> |
| 71 |
/// <exception cref="T:System.ArgumentNullException"> |
| 72 |
/// <paramref name="iteratorMethod" /> is null.</exception> |
| 73 |
[Experimental] |
| 74 |
public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, IEnumerable<IObservable<object>>>> iteratorMethod) |
| 75 |
{ |
| 76 |
if (provider == null) |
| 77 |
throw new ArgumentNullException("provider"); |
| 78 |
if (iteratorMethod == null) |
| 79 |
throw new ArgumentNullException("iteratorMethod"); |
| 80 |
|
| 81 |
return provider.CreateQuery<TResult>( |
| 82 |
Expression.Call( |
| 83 |
null, |
| 84 |
#if CRIPPLED_REFLECTION |
| 85 |
InfoOf(() => QbservableEx.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, IEnumerable<IObservable<object>>>>))), |
| 86 |
#else |
| 87 |
((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), |
| 88 |
#endif |
| 89 |
Expression.Constant(provider, typeof(IQbservableProvider)), |
| 90 |
iteratorMethod |
| 91 |
) |
| 92 |
); |
| 93 |
} |
| 94 |
#endif |
| 95 |
|
| 96 |
#if !STABLE |
| 97 |
/// <summary> |
| 98 |
/// Expands an observable sequence by recursively invoking selector. |
| 99 |
/// </summary> |
| 100 |
/// <typeparam name="TSource">The type of the elements in the source sequence and each of the recursively expanded sources obtained by running the selector function.</typeparam> |
| 101 |
/// <param name="source">Source sequence with the initial elements.</param> |
| 102 |
/// <param name="selector">Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.</param> |
| 103 |
/// <returns>An observable sequence containing all the elements produced by the recursive expansion.</returns> |
| 104 |
/// <exception cref="T:System.ArgumentNullException"> |
| 105 |
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception> |
| 106 |
[Experimental] |
| 107 |
public static IQbservable<TSource> Expand<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TSource>>> selector) |
| 108 |
{ |
| 109 |
if (source == null) |
| 110 |
throw new ArgumentNullException("source"); |
| 111 |
if (selector == null) |
| 112 |
throw new ArgumentNullException("selector"); |
| 113 |
|
| 114 |
return source.Provider.CreateQuery<TSource>( |
| 115 |
Expression.Call( |
| 116 |
null, |
| 117 |
#if CRIPPLED_REFLECTION |
| 118 |
InfoOf(() => QbservableEx.Expand<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TSource>>>))), |
| 119 |
#else |
| 120 |
((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), |
| 121 |
#endif |
| 122 |
source.Expression, |
| 123 |
selector |
| 124 |
) |
| 125 |
); |
| 126 |
} |
| 127 |
#endif |
| 128 |
|
| 129 |
#if !STABLE |
| 130 |
/// <summary> |
| 131 |
/// Expands an observable sequence by recursively invoking selector, using the specified scheduler to enumerate the queue of obtained sequences. |
| 132 |
/// </summary> |
| 133 |
/// <typeparam name="TSource">The type of the elements in the source sequence and each of the recursively expanded sources obtained by running the selector function.</typeparam> |
| 134 |
/// <param name="source">Source sequence with the initial elements.</param> |
| 135 |
/// <param name="selector">Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.</param> |
| 136 |
/// <param name="scheduler">Scheduler on which to perform the expansion by enumerating the internal queue of obtained sequences.</param> |
| 137 |
/// <returns>An observable sequence containing all the elements produced by the recursive expansion.</returns> |
| 138 |
/// <exception cref="T:System.ArgumentNullException"> |
| 139 |
/// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception> |
| 140 |
[Experimental] |
| 141 |
public static IQbservable<TSource> Expand<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TSource>>> selector, IScheduler scheduler) |
| 142 |
{ |
| 143 |
if (source == null) |
| 144 |
throw new ArgumentNullException("source"); |
| 145 |
if (selector == null) |
| 146 |
throw new ArgumentNullException("selector"); |
| 147 |
if (scheduler == null) |
| 148 |
throw new ArgumentNullException("scheduler"); |
| 149 |
|
| 150 |
return source.Provider.CreateQuery<TSource>( |
| 151 |
Expression.Call( |
| 152 |
null, |
| 153 |
#if CRIPPLED_REFLECTION |
| 154 |
InfoOf(() => QbservableEx.Expand<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TSource>>>), default(IScheduler))), |
| 155 |
#else |
| 156 |
((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), |
| 157 |
#endif |
| 158 |
source.Expression, |
| 159 |
selector, |
| 160 |
Expression.Constant(scheduler, typeof(IScheduler)) |
| 161 |
) |
| 162 |
); |
| 163 |
} |
| 164 |
#endif |
| 165 |
|
| 166 |
#if !STABLE |
| 167 |
/// <summary> |
| 168 |
/// Runs all specified observable sequences in parallel and collects their last elements. |
| 169 |
/// </summary> |
| 170 |
/// <param name="provider">Query provider used to construct the IQbservable<T> data source.</param> |
| 171 |
/// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam> |
| 172 |
/// <param name="sources">Observable sequence to collect the last elements for.</param> |
| 173 |
/// <returns>An observable sequence with an array collecting the last elements of all the input sequences.</returns> |
| 174 |
/// <exception cref="T:System.ArgumentNullException"> |
| 175 |
/// <paramref name="sources" /> is null.</exception> |
| 176 |
[Experimental] |
| 177 |
public static IQbservable<TSource[]> ForkJoin<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources) |
| 178 |
{ |
| 179 |
if (provider == null) |
| 180 |
throw new ArgumentNullException("provider"); |
| 181 |
if (sources == null) |
| 182 |
throw new ArgumentNullException("sources"); |
| 183 |
|
| 184 |
return provider.CreateQuery<TSource[]>( |
| 185 |
Expression.Call( |
| 186 |
null, |
| 187 |
#if CRIPPLED_REFLECTION |
| 188 |
InfoOf(() => QbservableEx.ForkJoin<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))), |
| 189 |
#else |
| 190 |
((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), |
| 191 |
#endif |
| 192 |
Expression.Constant(provider, typeof(IQbservableProvider)), |
| 193 |
GetSourceExpression(sources) |
| 194 |
) |
| 195 |
); |
| 196 |
} |
| 197 |
#endif |
| 198 |
|
| 199 |
#if !STABLE |
| 200 |
/// <summary> |
| 201 |
/// Runs all observable sequences in the enumerable sources sequence in parallel and collect their last elements. |
| 202 |
/// </summary> |
| 203 |
/// <param name="provider">Query provider used to construct the IQbservable<T> data source.</param> |
| 204 |
/// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam> |
| 205 |
/// <param name="sources">Observable sequence to collect the last elements for.</param> |
| 206 |
/// <returns>An observable sequence with an array collecting the last elements of all the input sequences.</returns> |
| 207 |
/// <exception cref="T:System.ArgumentNullException"> |
| 208 |
/// <paramref name="sources" /> is null.</exception> |
| 209 |
[Experimental] |
| 210 |
public static IQbservable<TSource[]> ForkJoin<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources) |
| 211 |
{ |
| 212 |
if (provider == null) |
| 213 |
throw new ArgumentNullException("provider"); |
| 214 |
if (sources == null) |
| 215 |
throw new ArgumentNullException("sources"); |
| 216 |
|
| 217 |
return provider.CreateQuery<TSource[]>( |
| 218 |
Expression.Call( |
| 219 |
null, |
| 220 |
#if CRIPPLED_REFLECTION |
| 221 |
InfoOf(() => QbservableEx.ForkJoin<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))), |
| 222 |
#else |
| 223 |
((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), |
| 224 |
#endif |
| 225 |
Expression.Constant(provider, typeof(IQbservableProvider)), |
| 226 |
GetSourceExpression(sources) |
| 227 |
) |
| 228 |
); |
| 229 |
} |
| 230 |
#endif |
| 231 |
|
| 232 |
#if !STABLE |
| 233 |
/// <summary> |
| 234 |
/// Runs two observable sequences in parallel and combines their last elemenets. |
| 235 |
/// </summary> |
| 236 |
/// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam> |
| 237 |
/// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam> |
| 238 |
/// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam> |
| 239 |
/// <param name="first">First observable sequence.</param> |
| 240 |
/// <param name="second">Second observable sequence.</param> |
| 241 |
/// <param name="resultSelector">Result selector function to invoke with the last elements of both sequences.</param> |
| 242 |
/// <returns>An observable sequence with the result of calling the selector function with the last elements of both input sequences.</returns> |
| 243 |
/// <exception cref="T:System.ArgumentNullException"> |
| 244 |
/// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception> |
| 245 |
[Experimental] |
| 246 |
public static IQbservable<TResult> ForkJoin<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector) |
| 247 |
{ |
| 248 |
if (first == null) |
| 249 |
throw new ArgumentNullException("first"); |
| 250 |
if (second == null) |
| 251 |
throw new ArgumentNullException("second"); |
| 252 |
if (resultSelector == null) |
| 253 |
throw new ArgumentNullException("resultSelector"); |
| 254 |
|
| 255 |
return first.Provider.CreateQuery<TResult>( |
| 256 |
Expression.Call( |
| 257 |
null, |
| 258 |
#if CRIPPLED_REFLECTION |
| 259 |
InfoOf(() => QbservableEx.ForkJoin<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))), |
| 260 |
#else |
| 261 |
((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)), |
| 262 |
#endif |
| 263 |
first.Expression, |
| 264 |
GetSourceExpression(second), |
| 265 |
resultSelector |
| 266 |
) |
| 267 |
); |
| 268 |
} |
| 269 |
#endif |
| 270 |
|
| 271 |
#if !STABLE |
| 272 |
/// <summary> |
| 273 |
/// Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. |
| 274 |
/// This operator allows for a fluent style of writing queries that use the same sequence multiple times. |
| 275 |
/// </summary> |
| 276 |
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam> |
| 277 |
/// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam> |
| 278 |
/// <param name="source">Source sequence that will be shared in the selector function.</param> |
| 279 |
/// <param name="selector">Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.</param> |
| 280 |
/// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns> |
| 281 |
/// <exception cref="T:System.ArgumentNullException"> |
| 282 |
/// <paramref name="source" /> or <paramref name="selector" /> is null.</exception> |
| 283 |
[Experimental] |
| 284 |
public static IQbservable<TResult> Let<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector) |
| 285 |
{ |
| 286 |
if (source == null) |
| 287 |
throw new ArgumentNullException("source"); |
| 288 |
if (selector == null) |
| 289 |
throw new ArgumentNullException("selector"); |
| 290 |
|
| 291 |
return source.Provider.CreateQuery<TResult>( |
| 292 |
Expression.Call( |
| 293 |
null, |
| 294 |
#if CRIPPLED_REFLECTION |
| 295 |
InfoOf(() => QbservableEx.Let<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))), |
| 296 |
#else |
| 297 |
((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), |
| 298 |
#endif |
| 299 |
source.Expression, |
| 300 |
selector |
| 301 |
) |
| 302 |
); |
| 303 |
} |
| 304 |
#endif |
| 305 |
|
| 306 |
#if !STABLE |
| 307 |
/// <summary> |
| 308 |
/// Comonadic bind operator. |
| 309 |
/// </summary> |
| 310 |
[Experimental] |
| 311 |
public static IQbservable<TResult> ManySelect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, TResult>> selector) |
| 312 |
{ |
| 313 |
if (source == null) |
| 314 |
throw new ArgumentNullException("source"); |
| 315 |
if (selector == null) |
| 316 |
throw new ArgumentNullException("selector"); |
| 317 |
|
| 318 |
return source.Provider.CreateQuery<TResult>( |
| 319 |
Expression.Call( |
| 320 |
null, |
| 321 |
#if CRIPPLED_REFLECTION |
| 322 |
InfoOf(() => QbservableEx.ManySelect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, TResult>>))), |
| 323 |
#else |
| 324 |
((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), |
| 325 |
#endif |
| 326 |
source.Expression, |
| 327 |
selector |
| 328 |
) |
| 329 |
); |
| 330 |
} |
| 331 |
#endif |
| 332 |
|
| 333 |
#if !STABLE |
| 334 |
/// <summary> |
| 335 |
/// Comonadic bind operator. |
| 336 |
/// </summary> |
| 337 |
[Experimental] |
| 338 |
public static IQbservable<TResult> ManySelect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, TResult>> selector, IScheduler scheduler) |
| 339 |
{ |
| 340 |
if (source == null) |
| 341 |
throw new ArgumentNullException("source"); |
| 342 |
if (selector == null) |
| 343 |
throw new ArgumentNullException("selector"); |
| 344 |
if (scheduler == null) |
| 345 |
throw new ArgumentNullException("scheduler"); |
| 346 |
|
| 347 |
return source.Provider.CreateQuery<TResult>( |
| 348 |
Expression.Call( |
| 349 |
null, |
| 350 |
#if CRIPPLED_REFLECTION |
| 351 |
InfoOf(() => QbservableEx.ManySelect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, TResult>>), default(IScheduler))), |
| 352 |
#else |
| 353 |
((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), |
| 354 |
#endif |
| 355 |
source.Expression, |
| 356 |
selector, |
| 357 |
Expression.Constant(scheduler, typeof(IScheduler)) |
| 358 |
) |
| 359 |
); |
| 360 |
} |
| 361 |
#endif |
| 362 |
|
| 363 |
} |
| 364 |
} |
| 365 |
|
| 366 |
#endif |
| 367 |
|
| 368 |
#pragma warning restore 1591 |
| 369 |
|