Observable.Queryable.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. #pragma warning disable 1591
  5. namespace System.Reactive.Linq
  6. {
  7. public static partial class Qbservable
  8. {
  9. private static IQbservableProvider s_provider;
  10. /// <summary>
  11. /// Gets the local query provider which will retarget Qbservable-based queries to the corresponding Observable-based query for in-memory execution upon subscription.
  12. /// </summary>
  13. public static IQbservableProvider Provider
  14. {
  15. get
  16. {
  17. if (s_provider == null)
  18. s_provider = new ObservableQueryProvider();
  19. return s_provider;
  20. }
  21. }
  22. /// <summary>
  23. /// Converts an in-memory observable sequence into an IQbservable&lt;T&gt; sequence with an expression tree representing the source sequence.
  24. /// </summary>
  25. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  26. /// <param name="source">Source sequence.</param>
  27. /// <returns>IQbservable&lt;T&gt; sequence representing the given observable source sequence.</returns>
  28. /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
  29. public static IQbservable<TSource> AsQbservable<TSource>(this IObservable<TSource> source)
  30. {
  31. if (source == null)
  32. throw new ArgumentNullException("source");
  33. return new ObservableQuery<TSource>(source);
  34. }
  35. }
  36. }
  37. #pragma warning restore 1591