예제 #1
0
                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);
                }
예제 #2
0
 private IEnumerable <PlatformVersion> ParseResultmacOS(SwVersResult result)
 {
     yield return(new PlatformVersion(result.ProductName.Replace(" ", ""), result.ProductVersion, "MacOSX")
     {
         Attributes =
         {
             BuildVersion(result),
             FriendlyName(result),
             "like MacOSX"
         }
     });
 }
예제 #3
0
            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"));
                }
            }
예제 #4
0
            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));
            }
예제 #5
0
 static string FriendlyName(SwVersResult result)
 {
     return("\"" + _FriendlyName(result.ProductVersion) + "\"");
 }
예제 #6
0
 static string BuildVersion(SwVersResult result)
 {
     return(string.Format("Build {0}", result.BuildVersion));
 }