QueryServices.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. using System;
  5. using System.Reactive.PlatformServices;
  6. namespace System.Reactive.Linq
  7. {
  8. internal static class QueryServices
  9. {
  10. private static IQueryServices s_services = Initialize();
  11. public static T GetQueryImpl<T>(T defaultInstance)
  12. {
  13. return s_services.Extend(defaultInstance);
  14. }
  15. private static IQueryServices Initialize()
  16. {
  17. #pragma warning disable CS0618 // Type or member is obsolete
  18. return PlatformEnlightenmentProvider.Current.GetService<IQueryServices>() ?? new DefaultQueryServices();
  19. #pragma warning restore CS0618 // Type or member is obsolete
  20. }
  21. }
  22. internal interface IQueryServices
  23. {
  24. T Extend<T>(T baseImpl);
  25. }
  26. class DefaultQueryServices : IQueryServices
  27. {
  28. public T Extend<T>(T baseImpl)
  29. {
  30. return baseImpl;
  31. }
  32. }
  33. }