EnvironmentInfo.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Threading.Tasks;
  6. using MediaBrowser.Model.System;
  7. namespace Emby.Common.Implementations.EnvironmentInfo
  8. {
  9. public class EnvironmentInfo : IEnvironmentInfo
  10. {
  11. public MediaBrowser.Model.System.OperatingSystem OperatingSystem
  12. {
  13. get
  14. {
  15. #if NET46
  16. switch (Environment.OSVersion.Platform)
  17. {
  18. case PlatformID.MacOSX:
  19. return MediaBrowser.Model.System.OperatingSystem.OSX;
  20. case PlatformID.Win32NT:
  21. return MediaBrowser.Model.System.OperatingSystem.Windows;
  22. case PlatformID.Unix:
  23. return MediaBrowser.Model.System.OperatingSystem.Linux;
  24. }
  25. #elif NETSTANDARD1_6
  26. if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
  27. {
  28. return OperatingSystem.OSX;
  29. }
  30. if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
  31. {
  32. return OperatingSystem.Windows;
  33. }
  34. if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
  35. {
  36. return OperatingSystem.Linux;
  37. }
  38. #endif
  39. return MediaBrowser.Model.System.OperatingSystem.Windows;
  40. }
  41. }
  42. public string OperatingSystemName
  43. {
  44. get
  45. {
  46. #if NET46
  47. return Environment.OSVersion.Platform.ToString();
  48. #elif NETSTANDARD1_6
  49. return System.Runtime.InteropServices.RuntimeInformation.OSDescription;
  50. #endif
  51. return "Operating System";
  52. }
  53. }
  54. public string OperatingSystemVersion
  55. {
  56. get
  57. {
  58. #if NET46
  59. return Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
  60. #elif NETSTANDARD1_6
  61. return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
  62. #endif
  63. return "1.0";
  64. }
  65. }
  66. }
  67. }