aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Common/SystemInfo/SystemInfo.cs
blob: 9ab1419c8a1a738842c1f01b563f12b8da0d7801 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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();
            }
        }
    }
}