PlatformEnlightenmentProvider.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.ComponentModel;
  5. namespace System.Reactive.PlatformServices
  6. {
  7. /// <summary>
  8. /// (Infrastructure) Interface for enlightenment providers.
  9. /// </summary>
  10. /// <remarks>
  11. /// This type is used by the Rx infrastructure and not meant for public consumption or implementation.
  12. /// No guarantees are made about forward compatibility of the type's functionality and its usage.
  13. /// </remarks>
  14. [EditorBrowsable(EditorBrowsableState.Never)]
  15. public interface IPlatformEnlightenmentProvider
  16. {
  17. /// <summary>
  18. /// (Infrastructure) Tries to gets the specified service.
  19. /// </summary>
  20. /// <typeparam name="T">Service type.</typeparam>
  21. /// <param name="args">Optional set of arguments.</param>
  22. /// <returns>Service instance or null if not found.</returns>
  23. T GetService<T>(params object[] args) where T : class;
  24. }
  25. /// <summary>
  26. /// (Infrastructure) Provider for platform-specific framework enlightenments.
  27. /// </summary>
  28. /// <remarks>
  29. /// This type is used by the Rx infrastructure and not meant for public consumption or implementation.
  30. /// </remarks>
  31. [EditorBrowsable(EditorBrowsableState.Never)]
  32. public static class PlatformEnlightenmentProvider
  33. {
  34. private static IPlatformEnlightenmentProvider _current = CreatePlatformProvider();
  35. /// <summary>
  36. /// (Infrastructure) Gets the current enlightenment provider. If none is loaded yet, accessing this property triggers provider resolution.
  37. /// </summary>
  38. /// <remarks>
  39. /// This member is used by the Rx infrastructure and not meant for public consumption or implementation.
  40. /// </remarks>
  41. [Obsolete("This mechanism will be removed in the next major version", false)]
  42. public static IPlatformEnlightenmentProvider Current
  43. {
  44. get
  45. {
  46. return _current;
  47. }
  48. set
  49. {
  50. _current = value ?? throw new ArgumentNullException(nameof(value));
  51. }
  52. }
  53. private static IPlatformEnlightenmentProvider CreatePlatformProvider() => new CurrentPlatformEnlightenmentProvider();
  54. }
  55. }