System.PlatformDetection.IsDistroAndVersion C# (CSharp) Method

IsDistroAndVersion() private static method

Get whether the OS platform matches the given Linux distro and optional version.
private static IsDistroAndVersion ( string distroId, string versionId = null ) : bool
distroId string The distribution id.
versionId string The distro version. If omitted, compares the distro only.
return bool
        private static bool IsDistroAndVersion(string distroId, string versionId = null)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                IdVersionPair v = ParseOsReleaseFile();
                if (v.Id == distroId && (versionId == null || v.VersionId == versionId))
                {
                    return true;
                }
            }

            return false;
        }