예제 #1
0
        /// <summary>
        /// Checks the update via RSS.
        /// </summary>
        /// <param name="uri">The URI.</param>
        private void CheckUpdateViaRss(Uri uri)
        {
            _updateList = new UpdateInfoList();
            XmlDocument doc = new XmlDocument();

            try {
                Stream strm = GetRssStream(uri);
                using ( strm ) {
                    doc.Load(strm);
                }
            } catch { throw; }
            XmlNamespaceManager nsm = CreateXmlNamespaceManager(doc);

            XmlNodeList updateInfoNodes = doc.SelectNodes(string.Format(Properties.Strings.UpdateInfoRootXPath, Properties.Strings.UpdateInfoNamespacePrefix), nsm);

            // Console.WriteLine ( "{0} Update info items found", updateInfoNodes.Count );

            foreach (XmlElement uie in updateInfoNodes)
            {
                try {
                    XmlParserContext xpc    = new XmlParserContext(doc.NameTable, nsm, string.Empty, XmlSpace.Preserve);
                    XmlTextReader    reader = new XmlTextReader(uie.OuterXml, XmlNodeType.Element, xpc);

                    XmlSerializer serializer = new XmlSerializer(typeof(UpdateInfo), nsm.LookupNamespace(Properties.Strings.UpdateInfoNamespacePrefix));
                    _updateList.Add(serializer.Deserialize(reader) as UpdateInfo);
                } catch (Exception ex) {
                    Console.WriteLine(ex.ToString());
                }
            }

            _updateList.Sort(new UpdateInfoVersionComparer());
            if (_updateList.Count > 0)
            {
                UpdateInfo _updateInfo = UpdateInfoList[UpdateInfoList.GetLatestVersion(  )];
                foreach (UpdateFile uf in _updateInfo.Files)
                {
                    if (uf.Version.CompareTo(this.Version) > 0)
                    {
                        _updatesAvailable = true;
                    }
                }
                if (_updatesAvailable || _updateInfo.Version.CompareTo(this.Version) > 0)
                {
                    OnUpdateAvailable(new UpdatesAvailableEventArgs(_updateInfo.Version));
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Gets the updates.
 /// </summary>
 public void GetUpdates()
 {
     GetUpdates(UpdateInfoList.GetLatestVersion());
 }