SystemInfo.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Runtime.InteropServices;
  2. namespace Ryujinx.Common.SystemInfo
  3. {
  4. public class SystemInfo
  5. {
  6. public virtual string OsDescription => $"{RuntimeInformation.OSDescription} ({RuntimeInformation.OSArchitecture})";
  7. public virtual string CpuName => "Unknown";
  8. public virtual ulong RamSize => 0;
  9. public string RamSizeInMB
  10. {
  11. get
  12. {
  13. if (RamSize == 0)
  14. {
  15. return "Unknown";
  16. }
  17. return $"{RamSize / 1024 / 1024} MB";
  18. }
  19. }
  20. public static SystemInfo Instance { get; }
  21. static SystemInfo()
  22. {
  23. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
  24. {
  25. Instance = new WindowsSysteminfo();
  26. }
  27. else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
  28. {
  29. Instance = new LinuxSysteminfo();
  30. }
  31. else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
  32. {
  33. Instance = new MacOSSysteminfo();
  34. }
  35. else
  36. {
  37. Instance = new SystemInfo();
  38. }
  39. }
  40. }
  41. }