Пример #1
0
        public OsInfo(IEnumerable <IOsVersionAdapter> versionAdapters, Logger logger)
        {
            OsVersionModel osInfo = null;

            foreach (var osVersionAdapter in versionAdapters.Where(c => c.Enabled))
            {
                try
                {
                    osInfo = osVersionAdapter.Read();
                }
                catch (Exception e)
                {
                    logger.Error(e, "Couldn't get OS Version info");
                }

                if (osInfo != null)
                {
                    break;
                }
            }

            if (osInfo != null)
            {
                Name     = osInfo.Name;
                Version  = osInfo.Version;
                FullName = osInfo.FullName;
            }
            else
            {
                Name     = Os.ToString();
                FullName = Name;
            }
        }
Пример #2
0
        public OsInfo(IEnumerable <IOsVersionAdapter> versionAdapters, Logger logger)
        {
            OsVersionModel osInfo = null;

            foreach (var osVersionAdapter in versionAdapters.Where(c => c.Enabled))
            {
                try
                {
                    osInfo = osVersionAdapter.Read();
                }
                catch (Exception e)
                {
                    logger.Error(e, "Couldn't get OS Version info");
                }

                if (osInfo != null)
                {
                    break;
                }
            }

            if (osInfo != null)
            {
                Name     = osInfo.Name;
                Version  = osInfo.Version;
                FullName = osInfo.FullName;
            }
            else
            {
                Name     = Os.ToString();
                FullName = Name;
            }

            if (IsLinux && File.Exists("/proc/1/cgroup") && File.ReadAllText("/proc/1/cgroup").Contains("/docker/"))
            {
                IsDocker = true;
            }
        }