summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions/AppcastReader.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2010-02-20 18:08:41 +0000
committersr55 <[email protected]>2010-02-20 18:08:41 +0000
commitb9d00019295781bed79eca280bac798b7bb7c64f (patch)
tree341aac9ec87d84d71be18a42afe0ee52ef497d3f /win/C#/Functions/AppcastReader.cs
parente5d5bc94b2217a9eb65857d83d31138d126947e4 (diff)
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
Diffstat (limited to 'win/C#/Functions/AppcastReader.cs')
-rw-r--r--win/C#/Functions/AppcastReader.cs96
1 files changed, 58 insertions, 38 deletions
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: <http://handbrake.fr>.
- 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: <http://handbrake.fr>.
+ 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;
+
+ /// <summary>
+ /// Appcast Reader - Used for parsing HandBrakes update file
+ /// </summary>
public class AppcastReader
{
/// <summary>
+ /// Gets Information about an update to HandBrake
+ /// </summary>
+ public Uri DescriptionUrl { get; private set; }
+
+ /// <summary>
+ /// Gets HandBrake's version from the appcast.xml file.
+ /// </summary>
+ public string Version { get; private set; }
+
+ /// <summary>
+ /// Gets HandBrake's Build from the appcast.xml file.
+ /// </summary>
+ public string Build { get; private set; }
+
+ /// <summary>
+ /// Gets the URL for update file.
+ /// </summary>
+ public string DownloadFile { get; private set; }
+
+ /// <summary>
/// Get the build information from the required appcasts. Run before accessing the public vars.
/// </summary>
+ /// <param name="input">
+ /// The input.
+ /// </param>
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
/// <summary>
/// Read the RSS file.
/// </summary>
- /// <param name="rssReader"></param>
- private static XmlNode readRss(XmlReader rssReader)
+ /// <param name="rssReader">
+ /// The RSS reader
+ /// </param>
+ /// <returns>
+ /// The read rss.
+ /// </returns>
+ 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;
}
-
- /// <summary>
- /// Get Information about an update to HandBrake
- /// </summary>
- public Uri DescriptionUrl { get; set; }
-
- /// <summary>
- /// Get HandBrake's version from the appcast.xml file.
- /// </summary>
- public string Version { get; set; }
-
- /// <summary>
- /// Get HandBrake's Build from the appcast.xml file.
- /// </summary>
- public string Build { get; set; }
-
- /// <summary>
- /// Get's the URL for update file.
- /// </summary>
- public string DownloadFile { get; set; }
}
} \ No newline at end of file