Exemple #1
0
        public AboutHost Get()
        {
            var a = new AboutHost {
                Version                = typeof(AboutHost).GetTypeInfo().Assembly.GetName().Version,
                OSDescription          = RuntimeInformation.OSDescription,
                Is64BitOperatingSystem = RuntimeInformation.OSArchitecture == Architecture.X64,
                Is64BitProcess         = RuntimeInformation.ProcessArchitecture == Architecture.X64,
                ProcessorCount         = Environment.ProcessorCount,
#if !NETSTANDARD1_6
                WorkingSet = Environment.WorkingSet,
#endif
                ConnectedUserCount = _sessionManager.GetUsers().Count()
            };

            var memoryInfo = _systemInfo.GetMemoryInformation();

            a.TotalVirtualMemory  = memoryInfo.TotalVirtualMemory;
            a.FreeVirtualMemory   = memoryInfo.FreeVirtualMemory;
            a.TotalPhysicalMemory = memoryInfo.TotalPhysicalMemory;
            a.FreePhysicalMemory  = memoryInfo.FreePhysicalMemory;

            a.VideoCards = _systemInfo.GetVideoControllerInformation().Select(ci =>
                                                                              new VideoCardInfo()
            {
                VideoCardName  = ci.VideoCardName,
                VideoRAM       = ci.VideoRAM,
                VideoProcessor = ci.VideoProcessor
            }).ToArray();

            var latest = _interpManager.Interpreters.Latest();

            a.Interpreters = _interpManager.Interpreters.Select(x => x.Id == latest.Id ? Invariant($"[{x.Id}] {x.Name} ({Resources.Default})") : Invariant($"[{x.Id}] {x.Name}")).ToArray();
            return(a);
        }
Exemple #2
0
        public AboutHost Get()
        {
            var a = new AboutHost();

            a.Version = Assembly.GetExecutingAssembly().GetName().Version;
            a.OS      = Environment.OSVersion;
            a.Is64BitOperatingSystem = Environment.Is64BitOperatingSystem;
            a.Is64BitProcess         = Environment.Is64BitProcess;
            a.ProcessorCount         = Environment.ProcessorCount;
            a.WorkingSet             = Environment.WorkingSet;
            a.ConnectedUserCount     = _sessionManager.GetUsers().Count();

            var query = new SelectQuery(@"Select * from Win32_OperatingSystem");

            using (var search = new ManagementObjectSearcher(query)) {
                foreach (var mo in search.Get())
                {
                    a.TotalVirtualMemory  = GetSizeInGB(mo, "TotalVirtualMemorySize");
                    a.FreeVirtualMemory   = GetSizeInGB(mo, "FreeVirtualMemory");
                    a.TotalPhysicalMemory = GetSizeInGB(mo, "TotalVisibleMemorySize");
                    a.FreePhysicalMemory  = GetSizeInGB(mo, "FreePhysicalMemory");
                    break;
                }
            }

            a.Interpreters = _interpManager.Interpreters.Select(x => x.Name).ToArray();
            return(a);
        }
Exemple #3
0
 private void GetVideoControllerInformation(ref AboutHost a)
 {
     using (var search = new ManagementObjectSearcher("Select * from Win32_VideoController")) {
         foreach (var mo in search.Get())
         {
             a.VideoCardName  = mo["Name"]?.ToString();
             a.VideoRAM       = ToLong(mo, "AdapterRAM", 1024 * 1024);
             a.VideoProcessor = mo["VideoProcessor"]?.ToString();
         }
     }
 }
Exemple #4
0
 private void GetMemoryInformation(ref AboutHost a)
 {
     using (var search = new ManagementObjectSearcher("Select * from Win32_OperatingSystem")) {
         foreach (var mo in search.Get())
         {
             a.TotalVirtualMemory  = ToLong(mo, "TotalVirtualMemorySize", 1024);
             a.FreeVirtualMemory   = ToLong(mo, "FreeVirtualMemory", 1024);
             a.TotalPhysicalMemory = ToLong(mo, "TotalVisibleMemorySize", 1024);
             a.FreePhysicalMemory  = ToLong(mo, "FreePhysicalMemory", 1024);
             break;
         }
     }
 }
        public static string IsHostVersionCompatible(this AboutHost aboutHost)
        {
            if (_localVersion.MajorRevision != 0 || _localVersion.MinorRevision != 0)   // Filter out debug builds
            {
                var serverVersion = new Version(aboutHost.Version.Major, aboutHost.Version.Minor);
                var clientVersion = new Version(_localVersion.Major, _localVersion.Minor);
                if (serverVersion > clientVersion)
                {
                    return(Resources.Error_RemoteVersionHigher.FormatInvariant(aboutHost.Version, _localVersion));
                }

                if (serverVersion < clientVersion)
                {
                    return(Resources.Error_RemoteVersionLower.FormatInvariant(aboutHost.Version, _localVersion));
                }
            }

            return(null);
        }
Exemple #6
0
        public AboutHost Get()
        {
            var a = new AboutHost();

            a.Version = Assembly.GetExecutingAssembly().GetName().Version;
            a.OS      = Environment.OSVersion;
            a.Is64BitOperatingSystem = Environment.Is64BitOperatingSystem;
            a.Is64BitProcess         = Environment.Is64BitProcess;
            a.ProcessorCount         = Environment.ProcessorCount;
            a.WorkingSet             = Environment.WorkingSet;
            a.ConnectedUserCount     = _sessionManager.GetUsers().Count();

            GetMemoryInformation(ref a);
            GetVideoControllerInformation(ref a);

            a.Interpreters = _interpManager.Interpreters.Select(x => Invariant($"[{x.Id}] {x.Name}")).ToArray();
            if (a.Interpreters.Length > 0)
            {
                a.Interpreters[0] = Invariant($"{a.Interpreters[0]} ({Resources.Default})");
            }
            return(a);
        }