static Platform() { #if __IOS__ var info = iOSHardware.GetModelAndArch(); Name = String.Format("{0} {1}", info.Item1, UIKit.UIDevice.CurrentDevice.SystemVersion); Architecture = info.Item2; #elif __ANDROID__ var info = AndroidHardware.GetModelAndArch(); Name = String.Format("{0} API{1}", info.Item1, (int)global::Android.OS.Build.VERSION.SdkInt); Architecture = info.Item2; #else var isWindows = Path.DirectorySeparatorChar == '\\'; if (isWindows) { Name = GetWindowsName(); Architecture = GetWindowsArchitecture(); } else { var buf = new utsname(); if (uname(ref buf) != 0) { Name = "Unknown"; Architecture = "Unknown"; } Architecture = Encoding.ASCII.GetString(buf.machine.TakeWhile(x => x != 0).ToArray()); var systemName = Encoding.ASCII.GetString(buf.sysname.TakeWhile(x => x != 0).ToArray()); var version = Encoding.ASCII.GetString(buf.release.TakeWhile(x => x != 0).ToArray()); if (systemName == "Darwin") { systemName = "OS X"; var darwinVesion = Int32.Parse(version.Split('.').First()); version = String.Format("10.{0}", darwinVesion - 4); } Name = String.Format("{0} {1}", systemName, version); } #endif }
private static extern int uname(ref utsname buf);