public static IEnumerable <UWPSDK> GetInstalledSDKs() { string windowsKit = UWPReferences.GetWindowsKit10(); IEnumerable <UWPSDK> result; if (string.IsNullOrEmpty(windowsKit)) { result = Enumerable.Empty <UWPSDK>(); } else { string path = UWPReferences.CombinePaths(new string[] { windowsKit, "Platforms", "UAP" }); if (!Directory.Exists(path)) { result = Enumerable.Empty <UWPSDK>(); } else { List <UWPSDK> list = new List <UWPSDK>(); string[] files = Directory.GetFiles(path, "*", SearchOption.AllDirectories); IEnumerable <string> enumerable = from f in files where string.Equals("Platform.xml", Path.GetFileName(f), StringComparison.OrdinalIgnoreCase) select f; foreach (string current in enumerable) { XDocument xDocument; try { xDocument = XDocument.Load(current); } catch { continue; } foreach (XElement current2 in xDocument.Elements("ApplicationPlatform")) { Version version; if (UWPReferences.FindVersionInNode(current2, out version)) { string s = (from e in current2.Elements("MinimumVisualStudioVersion") select e.Value).FirstOrDefault <string>(); list.Add(new UWPSDK(version, UWPReferences.TryParseVersion(s))); } } } result = list; } } return(result); }
private static bool FindVersionInNode(XElement node, out Version version) { bool result; for (XAttribute xAttribute = node.FirstAttribute; xAttribute != null; xAttribute = xAttribute.NextAttribute) { if (string.Equals(xAttribute.Name.LocalName, "version", StringComparison.OrdinalIgnoreCase)) { version = UWPReferences.TryParseVersion(xAttribute.Value); if (version != null) { result = true; return(result); } } } version = null; result = false; return(result); }