You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.5 KiB

4 years ago
  1. #if MYSQL_6_10
  2. // Copyright ?2004, 2018, Oracle and/or its affiliates. All rights reserved.
  3. //
  4. // MySQL Connector/NET is licensed under the terms of the GPLv2
  5. // <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
  6. // MySQL Connectors. There are special exceptions to the terms and
  7. // conditions of the GPLv2 as it is applied to this software, see the
  8. // FLOSS License Exception
  9. // <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
  10. //
  11. // This program is free software; you can redistribute it and/or modify
  12. // it under the terms of the GNU General Public License as published
  13. // by the Free Software Foundation; version 2 of the License.
  14. //
  15. // This program is distributed in the hope that it will be useful, but
  16. // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  18. // for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License along
  21. // with this program; if not, write to the Free Software Foundation, Inc.,
  22. // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. using System;
  24. using System.IO;
  25. using System.Runtime.InteropServices;
  26. namespace Externals.MySql.Data.Common
  27. {
  28. internal class Platform
  29. {
  30. private static bool _inited;
  31. private static bool _isMono;
  32. /// <summary>
  33. /// By creating a private ctor, we keep the compiler from creating a default ctor
  34. /// </summary>
  35. private Platform()
  36. {
  37. }
  38. public static bool IsWindows()
  39. {
  40. OperatingSystem os = Environment.OSVersion;
  41. switch (os.Platform)
  42. {
  43. case PlatformID.Win32NT:
  44. case PlatformID.Win32S:
  45. case PlatformID.Win32Windows:
  46. return true;
  47. }
  48. return false;
  49. }
  50. public static bool IsMacOSX()
  51. {
  52. #if NETFX
  53. return Environment.OSVersion.Platform == PlatformID.MacOSX;
  54. #else
  55. return RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
  56. #endif
  57. }
  58. public static bool IsMono()
  59. {
  60. if (!_inited)
  61. Init();
  62. return _isMono;
  63. }
  64. private static void Init()
  65. {
  66. _inited = true;
  67. Type t = Type.GetType("Mono.Runtime");
  68. _isMono = t != null;
  69. }
  70. public static bool IsDotNetCore()
  71. {
  72. return false;
  73. }
  74. }
  75. }
  76. #endif