EnlightenmentProvider.cs 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT License.
  3. // See the LICENSE file in the project root for more information.
  4. namespace System.Reactive.PlatformServices
  5. {
  6. /// <summary>
  7. /// Provides access to the platform enlightenments used by other Rx libraries to improve system performance and
  8. /// runtime efficiency. While Rx can run without platform enlightenments loaded, it's recommended to deploy the
  9. /// System.Reactive.PlatformServices assembly with your application and call <see cref="EnsureLoaded"/> during
  10. /// application startup to ensure enlightenments are properly loaded.
  11. /// </summary>
  12. public static class EnlightenmentProvider
  13. {
  14. /// <summary>
  15. /// Ensures that the calling assembly has a reference to the System.Reactive.PlatformServices assembly with
  16. /// platform enlightenments. If no reference is made from the user code, it's possible for the build process
  17. /// to drop the deployment of System.Reactive.PlatformServices, preventing its runtime discovery.
  18. /// </summary>
  19. /// <returns>
  20. /// true if the loaded enlightenment provider matches the provided defined in the current assembly; false
  21. /// otherwise. When a custom enlightenment provider is installed by the host, false will be returned.
  22. /// </returns>
  23. public static bool EnsureLoaded()
  24. {
  25. #pragma warning disable CS0618
  26. return PlatformEnlightenmentProvider.Current is CurrentPlatformEnlightenmentProvider;
  27. #pragma warning restore CS0618
  28. }
  29. }
  30. }