QueryServices.cs 1.0 KB

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