From b9d00019295781bed79eca280bac798b7bb7c64f Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 20 Feb 2010 18:08:41 +0000 Subject: WinGui: - Tied Microsoft StyleCop into the build process. - Included a settings file for StyleCop so anyone who picks up the project can use the global project settings. - Started Clearing up Warnings generated by stylecop. - Also included Resharper 5 config files that users can use. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3129 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Functions/AppcastReader.cs | 96 +++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 38 deletions(-) (limited to 'win/C#/Functions/AppcastReader.cs') diff --git a/win/C#/Functions/AppcastReader.cs b/win/C#/Functions/AppcastReader.cs index ea9cac112..7248ffa78 100644 --- a/win/C#/Functions/AppcastReader.cs +++ b/win/C#/Functions/AppcastReader.cs @@ -1,39 +1,64 @@ /* RssReader.cs $ - - This file is part of the HandBrake source code. - Homepage: . - It may be used under the terms of the GNU General Public License. */ - -using System; -using System.Xml; -using System.Text.RegularExpressions; -using System.IO; + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ namespace Handbrake.Functions { + using System; + using System.IO; + using System.Text.RegularExpressions; + using System.Xml; + + /// + /// Appcast Reader - Used for parsing HandBrakes update file + /// public class AppcastReader { + /// + /// Gets Information about an update to HandBrake + /// + public Uri DescriptionUrl { get; private set; } + + /// + /// Gets HandBrake's version from the appcast.xml file. + /// + public string Version { get; private set; } + + /// + /// Gets HandBrake's Build from the appcast.xml file. + /// + public string Build { get; private set; } + + /// + /// Gets the URL for update file. + /// + public string DownloadFile { get; private set; } + /// /// Get the build information from the required appcasts. Run before accessing the public vars. /// + /// + /// The input. + /// public void GetInfo(string input) { try { // Get the correct Appcast and set input. - XmlNode nodeItem = readRss(new XmlTextReader(new StringReader(input))); + XmlNode nodeItem = ReadRss(new XmlTextReader(new StringReader(input))); string result = nodeItem.InnerXml; // Regular Expressions Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\"""); Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""(([svn]*)([0-9.\s]*))\"""); - Build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""); - Version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", ""); - DownloadFile = nodeItem["windows"].InnerText; - DescriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText); - } - catch( Exception) + this.Build = ver.ToString().Replace("sparkle:version=", string.Empty).Replace("\"", string.Empty); + this.Version = verShort.ToString().Replace("sparkle:shortVersionString=", string.Empty).Replace("\"", string.Empty); + this.DownloadFile = nodeItem["windows"].InnerText; + this.DescriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText); + } + catch (Exception) { return; } @@ -42,8 +67,13 @@ namespace Handbrake.Functions /// /// Read the RSS file. /// - /// - private static XmlNode readRss(XmlReader rssReader) + /// + /// The RSS reader + /// + /// + /// The read rss. + /// + private static XmlNode ReadRss(XmlReader rssReader) { XmlNode nodeItem = null; XmlNode nodeChannel = null; @@ -55,44 +85,34 @@ namespace Handbrake.Functions foreach (XmlNode t in rssDoc.ChildNodes) { if (t.Name == "rss") + { nodeRss = t; + } } if (nodeRss != null) + { foreach (XmlNode t in nodeRss.ChildNodes) { if (t.Name == "channel") + { nodeChannel = t; + } } + } if (nodeChannel != null) + { foreach (XmlNode t in nodeChannel.ChildNodes) { if (t.Name == "item") + { nodeItem = t; + } } + } return nodeItem; } - - /// - /// Get Information about an update to HandBrake - /// - public Uri DescriptionUrl { get; set; } - - /// - /// Get HandBrake's version from the appcast.xml file. - /// - public string Version { get; set; } - - /// - /// Get HandBrake's Build from the appcast.xml file. - /// - public string Build { get; set; } - - /// - /// Get's the URL for update file. - /// - public string DownloadFile { get; set; } } } \ No newline at end of file -- cgit v1.2.3