public static SwVersResult Parse(IEnumerable <string> lines) { var result = new SwVersResult(); foreach (var line in lines) { string[] parts = (line ?? string.Empty).Split(new [] { ':' }, 2); switch (parts[0]) { case "ProductName": result.ProductName = parts[1].Trim(); break; case "ProductVersion": result.ProductVersion = parts[1].Trim(); break; case "BuildVersion": result.BuildVersion = parts[1].Trim(); break; } } if (string.IsNullOrEmpty(result.ProductName) || string.IsNullOrEmpty(result.ProductVersion) || string.IsNullOrEmpty(result.BuildVersion)) { return(null); } return(result); }
private IEnumerable <PlatformVersion> ParseResultmacOS(SwVersResult result) { yield return(new PlatformVersion(result.ProductName.Replace(" ", ""), result.ProductVersion, "MacOSX") { Attributes = { BuildVersion(result), FriendlyName(result), "like MacOSX" } }); }
private IEnumerable <PlatformVersion> ParseResultMacOSX(SwVersResult result) { yield return(new PlatformVersion(result.ProductName.Replace(" ", ""), result.ProductVersion, "MacOSX") { Attributes = { BuildVersion(result), FriendlyName(result), } }); // Easing branding into macOS if (string.Compare(result.ProductVersion, "10.12") > 0) { yield return(new PlatformVersion("macOS", result.ProductVersion, "MacOSX")); } }
internal IEnumerable <PlatformVersion> ParseResult(IEnumerable <string> lines) { if (lines == null) { return(Array.Empty <PlatformVersion>()); } var result = SwVersResult.Parse(lines); if (result == null) { return(Array.Empty <PlatformVersion>()); } if (result.ProductName == "macOS") { return(ParseResultmacOS(result)); } return(ParseResultMacOSX(result)); }
static string FriendlyName(SwVersResult result) { return("\"" + _FriendlyName(result.ProductVersion) + "\""); }
static string BuildVersion(SwVersResult result) { return(string.Format("Build {0}", result.BuildVersion)); }