Inheritance: IUpdateCondition
Exemplo n.º 1
0
        // http://learn.adobe.com/wiki/display/ADCdocs/Appcasting+RSS

        public IList <IUpdateTask> Read(string feed)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(feed);
            XmlNodeList nl = doc.SelectNodes("/rss/channel/item");

            List <IUpdateTask> ret = new List <IUpdateTask>();

            foreach (XmlNode n in nl)
            {
                ZippedFilesUpdateTask task = new ZippedFilesUpdateTask();
                if (n["warm-update"] != null && n["warm-update"].InnerText.ToLowerInvariant() == "true")
                {
                    task.Attributes.Add("warm-update", "true");
                }
                task.Description = n["description"].InnerText;
                string remotePath = n["enclosure"].Attributes["url"].Value;

                task.Attributes.Add("remotePath", remotePath);

                if (!remotePath.ToLowerInvariant().EndsWith(".zip"))
                {
                    throw new InvalidOperationException(
                              "Appcast feed contains urls which are not zip files. That isn't supported by this reader");
                }

                var version = _registry.VersionForCoreModule();
                if (n["appcast:module"] != null)
                {
                    version = _registry.VersionForModule(n["appcast:module"].InnerText);
                }
                var cnd = new VersionCondition(version);
                cnd.Attributes.Add("version", n["appcast:version"].InnerText);
                task.UpdateConditions.AddCondition(cnd, BooleanCondition.ConditionType.AND);

                ret.Add(task);
            }

            return(ret);
        }
        // http://learn.adobe.com/wiki/display/ADCdocs/Appcasting+RSS
        public IList<IUpdateTask> Read(string feed)
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(feed);
            XmlNodeList nl = doc.SelectNodes("/rss/channel/item");

            List<IUpdateTask> ret = new List<IUpdateTask>();

            foreach (XmlNode n in nl)
            {
                ZippedFilesUpdateTask task = new ZippedFilesUpdateTask();
                if(n["warm-update"] != null && n["warm-update"].InnerText.ToLowerInvariant() == "true")
                {
                    task.Attributes.Add("warm-update", "true");
                }
                task.Description = n["description"].InnerText;
                string remotePath = n["enclosure"].Attributes["url"].Value;

                task.Attributes.Add("remotePath", remotePath);

                if(!remotePath.ToLowerInvariant().EndsWith(".zip"))
                {
                    throw new InvalidOperationException(
                        "Appcast feed contains urls which are not zip files. That isn't supported by this reader");
                }

                var version = _registry.VersionForCoreModule();
                if(n["appcast:module"] != null)
                {
                    version = _registry.VersionForModule(n["appcast:module"].InnerText);
                }
                var cnd = new VersionCondition(version);
                cnd.Attributes.Add("version", n["appcast:version"].InnerText);
                task.UpdateConditions.AddCondition(cnd, BooleanCondition.ConditionType.AND);

                ret.Add(task);
            }

            return ret;
        }