Observable.Queryable.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. {
  19. s_provider = new ObservableQueryProvider();
  20. }
  21. return s_provider;
  22. }
  23. }
  24. /// <summary>
  25. /// Converts an in-memory observable sequence into an <see cref="IQbservable{T}"/> sequence with an expression tree representing the source sequence.
  26. /// </summary>
  27. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  28. /// <param name="source">Source sequence.</param>
  29. /// <returns><see cref="IQbservable{T}"/> sequence representing the given observable source sequence.</returns>
  30. /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
  31. public static IQbservable<TSource> AsQbservable<TSource>(this IObservable<TSource> source)
  32. {
  33. if (source == null)
  34. {
  35. throw new ArgumentNullException(nameof(source));
  36. }
  37. return new ObservableQuery<TSource>(source);
  38. }
  39. }
  40. }
  41. #pragma warning restore 1591