Example #1
0
        public IUpdateCheckResult CheckForUpdates(string updateURI)
        {
            UpdateCheckResult result = new UpdateCheckResult(updateURI, Substring(updateURI, 0, updateURI.LastIndexOf("/") + 1));

            List <IPackageInfo> allPackages = ReadUpdateFile(result);

            for (int i = 0; i < allPackages.Count; i++)
            {
                for (int reqs = 0; reqs < allPackages[i].Prerequisites.Count; reqs++)
                {
                    if (allPackages[i].Prerequisites[reqs].Version == -1)
                    {
                        IPackageInfo packageInfo = FindPackageByID(allPackages, allPackages[i].Prerequisites[reqs].FullID);
                        if (packageInfo != null)
                        {
                            allPackages[i].Prerequisites[reqs].Version = packageInfo.Version;
                        }
                    }
                }
                if (CanInstallPackage(allPackages[i]))
                {
                    // We need to install this package. So, let's read the rest of the data
                    ((PackageInfo)allPackages[i]).ReadFullFromXml(XmlReader.Create(result.UpdateDirectory + "Packages/" + allPackages[i].FullID + "/" + allPackages[i].FullID + ".xml"));
                    // And add it to the list of packages in the update
                    result.PackagesToUpdate.Add(allPackages[i]);
                }
            }

            return(result);
        }
Example #2
0
        private List <IPackageInfo> ReadUpdateFile(UpdateCheckResult updateResult)
        {
            List <IPackageInfo> packageInfoList = new List <IPackageInfo>();

            using (XmlReader reader = XmlReader.Create(updateResult.UpdateURI)) {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name)
                        {
                        case "Package": {
                            PackageInfo package = new PackageInfo();
                            package.ReadBasicFromXml(reader);
                            packageInfoList.Add(package);
                        }
                        break;
                        }
                    }
                }
            }

            return(packageInfoList);
        }