From de212f8b98eaa1207aefe1bb7896dd43b11144d6 Mon Sep 17 00:00:00 2001 From: Keivan Date: Mon, 27 Sep 2010 23:09:24 -0700 Subject: [PATCH] Fixed some resharper line breaks --- NzbDrone.Core/Providers/ConfigProvider.cs | 20 ++++++++++++---- NzbDrone.Core/Providers/DiskProvider.cs | 3 ++- NzbDrone.Core/Providers/EpisodeProvider.cs | 28 ++++++++++++---------- NzbDrone.Core/Providers/SabProvider.cs | 15 ++++++------ NzbDrone.Core/Providers/SeriesProvider.cs | 3 ++- NzbDrone.Core/Providers/TvDbProvider.cs | 4 ++-- 6 files changed, 44 insertions(+), 29 deletions(-) diff --git a/NzbDrone.Core/Providers/ConfigProvider.cs b/NzbDrone.Core/Providers/ConfigProvider.cs index 303cfeb92..19f0bdc90 100644 --- a/NzbDrone.Core/Providers/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/ConfigProvider.cs @@ -36,10 +36,12 @@ public string GetValue(string key, object defaultValue, bool makePermanent) var dbValue = _sonicRepo.Single(key); - if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value)) return dbValue.Value; + if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value)) + return dbValue.Value; _logger.WarnFormat("Unable to find config key '{0}' defaultValue:'{1}'", key, defaultValue); - if (makePermanent) SetValue(key, defaultValue.ToString()); + if (makePermanent) + SetValue(key, defaultValue.ToString()); value = defaultValue.ToString(); return value; @@ -47,14 +49,22 @@ public string GetValue(string key, object defaultValue, bool makePermanent) public void SetValue(string key, string value) { - if (String.IsNullOrEmpty(key)) throw new ArgumentOutOfRangeException("key"); - if (value == null) throw new ArgumentNullException("key"); + if (String.IsNullOrEmpty(key)) + throw new ArgumentOutOfRangeException("key"); + if (value == null) + throw new ArgumentNullException("key"); _logger.DebugFormat("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value); var dbValue = _sonicRepo.Single(key); - if (dbValue == null) _sonicRepo.Add(new Config {Key = key, Value = value}); + if (dbValue == null) + { + _sonicRepo.Add(new Config { + Key = key, + Value = value + }); + } else { dbValue.Value = value; diff --git a/NzbDrone.Core/Providers/DiskProvider.cs b/NzbDrone.Core/Providers/DiskProvider.cs index 785cb78ae..b4062b1f0 100644 --- a/NzbDrone.Core/Providers/DiskProvider.cs +++ b/NzbDrone.Core/Providers/DiskProvider.cs @@ -26,7 +26,8 @@ public String CreateDirectory(string path) public static string CleanPath(string path) { - if (string.IsNullOrEmpty(path)) throw new ArgumentException("Path can not be null or empty"); + if (string.IsNullOrEmpty(path)) + throw new ArgumentException("Path can not be null or empty"); return path.ToLower().Trim('/', '\\', ' '); } } diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index 1f059a3f0..fb9c3daa5 100644 --- a/NzbDrone.Core/Providers/EpisodeProvider.cs +++ b/NzbDrone.Core/Providers/EpisodeProvider.cs @@ -1,4 +1,3 @@ -using System; using System.Text.RegularExpressions; using NzbDrone.Core.Repository; @@ -6,7 +5,7 @@ namespace NzbDrone.Core.Providers { public class EpisodeProvider { - private static readonly Regex _parseRegex = new Regex(@"(?.*) + private static readonly Regex ParseRegex = new Regex(@"(?.*) (?: s(?\d+)e(?\d+)-?e(?\d+) | s(?\d+)e(?\d+) @@ -23,16 +22,26 @@ public class EpisodeProvider public static Episode Parse(string title) { - Match match = _parseRegex.Match(title); + Match match = ParseRegex.Match(title); - if (!match.Success) return null; + if (!match.Success) + return null; - return new Episode {Season = ParseInt(match.Groups["seasonNumber"].Value), EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value), EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value), Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value), Release = ReplaceSeparatorChars(match.Groups["release"].Value), Proper = title.Contains("PROPER")}; + return new Episode { + Season = ParseInt(match.Groups["seasonNumber"].Value), + EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value), + EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value), + Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value), + Release = ReplaceSeparatorChars(match.Groups["release"].Value), + Proper = title.Contains("PROPER") + }; } private static string ReplaceSeparatorChars(string s) { - if (s == null) return string.Empty; + if (s == null) + return string.Empty; + return s.Replace('.', ' ').Replace('-', ' ').Replace('_', ' ').Trim(); } @@ -42,12 +51,5 @@ private static int ParseInt(string s) int.TryParse(s, out i); return i; } - - private static DateTime ParseAirDate(string s) - { - DateTime d; - if (DateTime.TryParse(ReplaceSeparatorChars(s).Replace(' ', '-'), out d)) return d; - return DateTime.MinValue; - } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/SabProvider.cs b/NzbDrone.Core/Providers/SabProvider.cs index 90f6f943c..664c681a9 100644 --- a/NzbDrone.Core/Providers/SabProvider.cs +++ b/NzbDrone.Core/Providers/SabProvider.cs @@ -37,28 +37,29 @@ public bool AddByUrl(string url, string title) string response = _http.DownloadString(request).Replace("\n", String.Empty); _logger.DebugFormat("Queue Repsonse: [{0}]", response); - if (response == "ok") return true; + if (response == "ok") + return true; return false; } public bool IsInQueue(string title) { - string action = "mode=queue&output=xml"; + const string action = "mode=queue&output=xml"; string request = GetSabRequest(action); string response = _http.DownloadString(request); XDocument xDoc = XDocument.Parse(response); //If an Error Occurred, retuyrn) - if (xDoc.Descendants("error").Count() != 0) return false; + if (xDoc.Descendants("error").Count() != 0) + return false; - if (xDoc.Descendants("queue").Count() == 0) return false; + if (xDoc.Descendants("queue").Count() == 0) + return false; //Get the Count of Items in Queue where 'filename' is Equal to goodName, if not zero, return true (isInQueue))) - if ((from s in xDoc.Descendants("slot") - where s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase) - select s).Count() != 0) + if ((xDoc.Descendants("slot").Where(s => s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase))).Count() != 0) { _logger.DebugFormat("Episode in queue - '{0}'", title); diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index e0f75d4f1..6518bffd7 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -54,7 +54,8 @@ public void SyncSeriesWithDisk() private void AddShow(string path) { var searchResults = _tvDb.SearchSeries(new DirectoryInfo(path).Name); - if (searchResults.Count != 0 && !_sonioRepo.Exists(s => s.TvdbId == searchResults[0].Id.ToString())) AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language)); + if (searchResults.Count != 0 && !_sonioRepo.Exists(s => s.TvdbId == searchResults[0].Id.ToString())) + AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language)); } private void AddShow(string path, TvdbSeries series) diff --git a/NzbDrone.Core/Providers/TvDbProvider.cs b/NzbDrone.Core/Providers/TvDbProvider.cs index c86312383..5f02aff0e 100644 --- a/NzbDrone.Core/Providers/TvDbProvider.cs +++ b/NzbDrone.Core/Providers/TvDbProvider.cs @@ -8,12 +8,12 @@ namespace NzbDrone.Core.Providers { public class TvDbProvider : ITvDbProvider { - private const string TvDbApiKey = "5D2D188E86E07F4F"; + private const string TVDB_APIKEY = "5D2D188E86E07F4F"; private readonly TvdbHandler _handler; public TvDbProvider() { - _handler = new TvdbHandler(new XmlCacheProvider(Path.Combine(Main.AppPath, @"cache\tvdbcache.xml")), TvDbApiKey); + _handler = new TvdbHandler(new XmlCacheProvider(Path.Combine(Main.AppPath, @"cache\tvdbcache.xml")), TVDB_APIKEY); } #region ITvDbProvider Members