QueryServices.cs 901 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. using System;
  3. using System.Reactive.PlatformServices;
  4. namespace System.Reactive.Linq
  5. {
  6. internal static class QueryServices
  7. {
  8. private static IQueryServices s_services = Initialize();
  9. public static T GetQueryImpl<T>(T defaultInstance)
  10. {
  11. return s_services.Extend(defaultInstance);
  12. }
  13. private static IQueryServices Initialize()
  14. {
  15. return PlatformEnlightenmentProvider.Current.GetService<IQueryServices>() ?? new DefaultQueryServices();
  16. }
  17. }
  18. internal interface IQueryServices
  19. {
  20. T Extend<T>(T baseImpl);
  21. }
  22. class DefaultQueryServices : IQueryServices
  23. {
  24. public T Extend<T>(T baseImpl)
  25. {
  26. return baseImpl;
  27. }
  28. }
  29. }