Refactor SystemInfo and implement macOS system info backend (#1177)

This commit is contained in:
Mary 2020-05-04 04:15:27 +02:00 committed by GitHub
parent 4c54f36c38
commit 651a07c6c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 187 additions and 45 deletions

View file

@ -0,0 +1,46 @@
using System.Runtime.InteropServices;
namespace Ryujinx.Common.SystemInfo
{
public class SystemInfo
{
public virtual string OsDescription => $"{RuntimeInformation.OSDescription} ({RuntimeInformation.OSArchitecture})";
public virtual string CpuName => "Unknown";
public virtual ulong RamSize => 0;
public string RamSizeInMB
{
get
{
if (RamSize == 0)
{
return "Unknown";
}
return $"{RamSize / 1024 / 1024} MB";
}
}
public static SystemInfo Instance { get; }
static SystemInfo()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Instance = new WindowsSysteminfo();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Instance = new LinuxSysteminfo();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Instance = new MacOSSysteminfo();
}
else
{
Instance = new SystemInfo();
}
}
}
}