From 72d3f2ea491550a1ded2ac292f3f2d7e16bc7921 Mon Sep 17 00:00:00 2001 From: Jay Otterbein Date: Thu, 3 Nov 2016 19:49:29 -0500 Subject: [PATCH] normalized line endings and removed unused usings --- src/Jackett/Utils/ParseUtil.cs | 111 +++++++++++++++------------------ 1 file changed, 52 insertions(+), 59 deletions(-) diff --git a/src/Jackett/Utils/ParseUtil.cs b/src/Jackett/Utils/ParseUtil.cs index a5df6e2a1..89bb8693d 100644 --- a/src/Jackett/Utils/ParseUtil.cs +++ b/src/Jackett/Utils/ParseUtil.cs @@ -1,67 +1,60 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Jackett.Utils -{ - public static class ParseUtil - { +using System.Globalization; + +namespace Jackett.Utils +{ + public static class ParseUtil + { public static string NormalizeSpace(string s) { return s.Trim(); - } - + } + public static string NormalizeNumber(string s) { - string normalized = NormalizeSpace(s); + var normalized = NormalizeSpace(s); normalized = normalized.Replace("-", "0"); normalized = normalized.Replace(",", ""); return normalized; - } - - public static double CoerceDouble(string str) - { - return double.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture); - } - - public static float CoerceFloat(string str) - { - return float.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture); - } - - public static int CoerceInt(string str) - { - return int.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture); - } - - public static long CoerceLong(string str) - { - return long.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture); - } - - - public static bool TryCoerceDouble(string str, out double result) - { - return double.TryParse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture, out result); - } - - public static bool TryCoerceFloat(string str, out float result) - { - return float.TryParse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture, out result); - } - - public static bool TryCoerceInt(string str, out int result) - { - return int.TryParse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture, out result); - } - - public static bool TryCoerceLong(string str, out long result) - { - return long.TryParse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture, out result); - } - - } -} + } + + public static double CoerceDouble(string str) + { + return double.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture); + } + + public static float CoerceFloat(string str) + { + return float.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture); + } + + public static int CoerceInt(string str) + { + return int.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture); + } + + public static long CoerceLong(string str) + { + return long.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture); + } + + public static bool TryCoerceDouble(string str, out double result) + { + return double.TryParse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture, out result); + } + + public static bool TryCoerceFloat(string str, out float result) + { + return float.TryParse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture, out result); + } + + public static bool TryCoerceInt(string str, out int result) + { + return int.TryParse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture, out result); + } + + public static bool TryCoerceLong(string str, out long result) + { + return long.TryParse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture, out result); + } + } +} \ No newline at end of file