using System.Runtime.InteropServices; using Mlaumcherb.Client.Avalonia.классы; // ReSharper disable CollectionNeverUpdated.Global namespace Mlaumcherb.Client.Avalonia.холопы; public static class PlatformHelper { public static bool CheckOs(Os os) => os.name switch { null => true, "osx" => OperatingSystem.IsMacOS(), "linux" => OperatingSystem.IsLinux(), "windows" => OperatingSystem.IsWindows(), _ => throw new ArgumentOutOfRangeException(os.name) } && os.arch switch { null => true, "i386" or "x86" => RuntimeInformation.OSArchitecture == Architecture.X86, "x64" => RuntimeInformation.OSArchitecture == Architecture.X64, "arm64" => RuntimeInformation.OSArchitecture == Architecture.Arm64, _ => false }; public static string GetOs() => Environment.OSVersion.Platform switch { PlatformID.Win32NT => "windows", PlatformID.Unix => "linux", PlatformID.MacOSX => "osx", _ => throw new PlatformNotSupportedException("OS not supported") }; public static string GetArch() => RuntimeInformation.OSArchitecture switch { Architecture.X86 => "x86", Architecture.X64 => "x64", Architecture.Arm64 => "arm64", _ => throw new PlatformNotSupportedException("OS not supported") }; public static string GetArchOld() => RuntimeInformation.OSArchitecture switch { Architecture.X86 => "32", Architecture.X64 => "64", _ => throw new PlatformNotSupportedException("OS not supported") }; public static string GetOsAndArch() => GetOs() + '-' + GetArch(); }