diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-21 12:22:22 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-21 12:22:41 -0500 |
| commit | 5e08d95b92bccd86109a11a347746d643531a1ed (patch) | |
| tree | 3b3fde363b495e04ab06d75bbce83d028bcd88c7 /MediaBrowser.Common | |
| parent | 3bac0a516fe074404d815341a7064c1e13c24c6b (diff) | |
fixed x64
Diffstat (limited to 'MediaBrowser.Common')
| -rw-r--r-- | MediaBrowser.Common/Extensions/XmlExtensions.cs | 201 | ||||
| -rw-r--r-- | MediaBrowser.Common/MediaBrowser.Common.csproj | 1 |
2 files changed, 0 insertions, 202 deletions
diff --git a/MediaBrowser.Common/Extensions/XmlExtensions.cs b/MediaBrowser.Common/Extensions/XmlExtensions.cs deleted file mode 100644 index 6f626d328..000000000 --- a/MediaBrowser.Common/Extensions/XmlExtensions.cs +++ /dev/null @@ -1,201 +0,0 @@ -using System; -using System.Globalization; -using System.Xml; - -namespace MediaBrowser.Common.Extensions -{ - /// <summary> - /// Class XmlExtensions - /// </summary> - public static class XmlExtensions - { - - /// <summary> - /// Safes the get int32. - /// </summary> - /// <param name="doc">The doc.</param> - /// <param name="path">The path.</param> - /// <returns>System.Int32.</returns> - public static int SafeGetInt32(this XmlDocument doc, string path) - { - return SafeGetInt32(doc, path, 0); - } - - /// <summary> - /// Safes the get int32. - /// </summary> - /// <param name="doc">The doc.</param> - /// <param name="path">The path.</param> - /// <param name="defaultInt">The default int.</param> - /// <returns>System.Int32.</returns> - public static int SafeGetInt32(this XmlDocument doc, string path, int defaultInt) - { - XmlNode rvalNode = doc.SelectSingleNode(path); - if (rvalNode != null && rvalNode.InnerText.Length > 0) - { - int rval; - if (Int32.TryParse(rvalNode.InnerText, out rval)) - { - return rval; - } - - } - return defaultInt; - } - - /// <summary> - /// The _us culture - /// </summary> - private static readonly CultureInfo _usCulture = new CultureInfo("en-US"); - - /// <summary> - /// Safes the get single. - /// </summary> - /// <param name="doc">The doc.</param> - /// <param name="path">The path.</param> - /// <param name="minValue">The min value.</param> - /// <param name="maxValue">The max value.</param> - /// <returns>System.Single.</returns> - public static float SafeGetSingle(this XmlDocument doc, string path, float minValue, float maxValue) - { - XmlNode rvalNode = doc.SelectSingleNode(path); - if (rvalNode != null && rvalNode.InnerText.Length > 0) - { - float rval; - // float.TryParse is local aware, so it can be probamatic, force us culture - if (float.TryParse(rvalNode.InnerText, NumberStyles.AllowDecimalPoint, _usCulture, out rval)) - { - if (rval >= minValue && rval <= maxValue) - { - return rval; - } - } - - } - return minValue; - } - - - /// <summary> - /// Safes the get string. - /// </summary> - /// <param name="doc">The doc.</param> - /// <param name="path">The path.</param> - /// <returns>System.String.</returns> - public static string SafeGetString(this XmlDocument doc, string path) - { - return SafeGetString(doc, path, null); - } - - /// <summary> - /// Safes the get string. - /// </summary> - /// <param name="doc">The doc.</param> - /// <param name="path">The path.</param> - /// <param name="defaultString">The default string.</param> - /// <returns>System.String.</returns> - public static string SafeGetString(this XmlDocument doc, string path, string defaultString) - { - XmlNode rvalNode = doc.SelectSingleNode(path); - if (rvalNode != null && rvalNode.InnerText.Trim().Length > 0) - { - return rvalNode.InnerText; - } - return defaultString; - } - - /// <summary> - /// Safes the get string. - /// </summary> - /// <param name="doc">The doc.</param> - /// <param name="path">The path.</param> - /// <returns>System.String.</returns> - public static string SafeGetString(this XmlNode doc, string path) - { - return SafeGetString(doc, path, null); - } - - /// <summary> - /// Safes the get string. - /// </summary> - /// <param name="doc">The doc.</param> - /// <param name="path">The path.</param> - /// <param name="defaultValue">The default value.</param> - /// <returns>System.String.</returns> - public static string SafeGetString(this XmlNode doc, string path, string defaultValue) - { - XmlNode rvalNode = doc.SelectSingleNode(path); - if (rvalNode != null && rvalNode.InnerText.Length > 0) - { - return rvalNode.InnerText; - } - return defaultValue; - } - - /// <summary> - /// Reads the string safe. - /// </summary> - /// <param name="reader">The reader.</param> - /// <returns>System.String.</returns> - public static string ReadStringSafe(this XmlReader reader) - { - var val = reader.ReadElementContentAsString(); - - return string.IsNullOrWhiteSpace(val) ? null : val; - } - - /// <summary> - /// Reads the value safe. - /// </summary> - /// <param name="reader">The reader.</param> - /// <returns>System.String.</returns> - public static string ReadValueSafe(this XmlReader reader) - { - reader.Read(); - - var val = reader.Value; - - return string.IsNullOrWhiteSpace(val) ? null : val; - } - - /// <summary> - /// Reads a float from the current element of an XmlReader - /// </summary> - /// <param name="reader">The reader.</param> - /// <returns>System.Single.</returns> - public static float ReadFloatSafe(this XmlReader reader) - { - string valueString = reader.ReadElementContentAsString(); - - float value = 0; - - if (!string.IsNullOrWhiteSpace(valueString)) - { - // float.TryParse is local aware, so it can be probamatic, force us culture - float.TryParse(valueString, NumberStyles.AllowDecimalPoint, _usCulture, out value); - } - - return value; - } - - /// <summary> - /// Reads an int from the current element of an XmlReader - /// </summary> - /// <param name="reader">The reader.</param> - /// <returns>System.Int32.</returns> - public static int ReadIntSafe(this XmlReader reader) - { - string valueString = reader.ReadElementContentAsString(); - - int value = 0; - - if (!string.IsNullOrWhiteSpace(valueString)) - { - - int.TryParse(valueString, out value); - } - - return value; - } - } -}
\ No newline at end of file diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index 8929f4bd5..fa4d956db 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -132,7 +132,6 @@ <Compile Include="Events\GenericEventArgs.cs" /> <Compile Include="Extensions\NamedLock.cs" /> <Compile Include="Extensions\ResourceNotFoundException.cs" /> - <Compile Include="Extensions\XmlExtensions.cs" /> <Compile Include="IO\FileSystem.cs" /> <Compile Include="IO\FileSystemRepository.cs" /> <Compile Include="IO\IIsoManager.cs" /> |
