Platform.cs 981 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Runtime.InteropServices;
  2. #pragma warning disable 1591
  3. namespace OpenCvSharp.Internal.Util;
  4. // ReSharper disable once InconsistentNaming
  5. internal enum OS
  6. {
  7. Windows,
  8. Unix
  9. }
  10. internal enum Runtime
  11. {
  12. DotNet,
  13. Mono
  14. }
  15. /// <summary>
  16. /// Provides information for the platform which the user is using
  17. /// </summary>
  18. internal static class Platform
  19. {
  20. /// <summary>
  21. /// OS type
  22. /// </summary>
  23. // ReSharper disable once InconsistentNaming
  24. public static readonly OS OS;
  25. /// <summary>
  26. /// Runtime type
  27. /// </summary>
  28. public static readonly Runtime Runtime;
  29. #pragma warning disable CA1810
  30. static Platform()
  31. #pragma warning restore CA1810
  32. {
  33. OS = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
  34. RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
  35. ? OS.Unix
  36. : OS.Windows;
  37. Runtime = (Type.GetType("Mono.Runtime") is null) ? Runtime.Mono : Runtime.DotNet;
  38. }
  39. }