Example #1
0
		/// <summary>
		/// Detects the unix.
		/// </summary>
		/// <param name="isLinux">if set to <c>true</c> [is linux].</param>
		/// <param name="isUnix">if set to <c>true</c> [is unix].</param>
		/// <param name="platformIdentity">The platform OS.</param>
		private static void DetectUnix(out bool isLinux, out bool isUnix, out PlatformIdentity platformIdentity)
		{
			string kernelName = DetectUnixKernel();

			switch (kernelName)
			{
				case null:
				case "":
					throw new PlatformNotSupportedException("Unknown platform");

				case "Linux":
					isLinux = true;
					isUnix = false;
					platformIdentity = PlatformIdentity.Linux;
					break;

				case "Darwin":
					isLinux = isUnix = true;
					platformIdentity = PlatformIdentity.MacOSX;
					break;

				default:
					isLinux = false;
					isUnix = true;
					platformIdentity = PlatformIdentity.Unix;
					break;
			}
		}
Example #2
0
		/// <summary>
		/// Initializes the <see cref="Platform"/> class.
		/// </summary>
		static Platform()
		{
			Is64Bits = Environment.Is64BitProcess;
			Is32Bits = !Is64Bits;

			PlatformID osplatform = Environment.OSVersion.Platform;

			switch (osplatform)
			{
				case PlatformID.Win32NT:
				case PlatformID.Win32S:
				case PlatformID.Win32Windows:
				case PlatformID.WinCE:
					IsWindows = true;
					PlatformIdentity = PlatformIdentity.Windows;
					break;

				case PlatformID.MacOSX:
					IsMacOSX = true;
					PlatformIdentity = PlatformIdentity.MacOSX;
					break;

				case PlatformID.Unix:
					DetectUnix(out IsLinux, out IsUnix, out PlatformIdentity);
					break;

				default:
					if (osplatform == (PlatformID) 4)
						DetectUnix(out IsLinux, out IsUnix, out PlatformIdentity);

					break;
			}
		}