Ejemplo n.º 1
0
        public static IEnumerable <Version> GetInstalledSDKVersions()
        {
            string windowsKit = UWPReferences.GetWindowsKit10();
            IEnumerable <Version> result;

            if (string.IsNullOrEmpty(windowsKit))
            {
                result = new Version[0];
            }
            else
            {
                string path = UWPReferences.CombinePaths(new string[]
                {
                    windowsKit,
                    "Platforms",
                    "UAP"
                });
                if (!Directory.Exists(path))
                {
                    result = new Version[0];
                }
                else
                {
                    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;
                    List <Version> list = new List <Version>();
                    foreach (string current in enumerable)
                    {
                        XDocument xDocument;
                        try
                        {
                            xDocument = XDocument.Load(current);
                        }
                        catch
                        {
                            continue;
                        }
                        foreach (XNode current2 in xDocument.Nodes())
                        {
                            XElement xElement = current2 as XElement;
                            if (xElement != null)
                            {
                                Version item;
                                if (UWPReferences.FindVersionInNode(xElement, out item))
                                {
                                    list.Add(item);
                                }
                            }
                        }
                    }
                    result = list;
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        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);
        }