EnlightenmentProvider.cs 1.7 KB

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