ReSharper code cleanup

This commit is contained in:
kay.one 2011-04-09 19:44:01 -07:00
commit e896af5cd0
138 changed files with 2368 additions and 2218 deletions

View file

@ -1,18 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
namespace NzbDrone.Web.Models
{
#region Models
[PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = "The new password and confirmation password do not match.")]
[PropertiesMustMatch("NewPassword", "ConfirmPassword",
ErrorMessage = "The new password and confirmation password do not match.")]
public class ChangePasswordModel
{
[Required]
@ -47,7 +45,8 @@ namespace NzbDrone.Web.Models
public bool RememberMe { get; set; }
}
[PropertiesMustMatch("Password", "ConfirmPassword", ErrorMessage = "The password and confirmation password do not match.")]
[PropertiesMustMatch("Password", "ConfirmPassword",
ErrorMessage = "The password and confirmation password do not match.")]
public class RegisterModel
{
[Required]
@ -70,9 +69,11 @@ namespace NzbDrone.Web.Models
[DisplayName("Confirm password")]
public string ConfirmPassword { get; set; }
}
#endregion
#region Services
// The FormsAuthentication type is sealed and contains static members, so it is difficult to
// unit test code that calls its members. The interface and helper class below demonstrate
// how to create an abstract wrapper around such a type in order to make the AccountController
@ -101,26 +102,29 @@ namespace NzbDrone.Web.Models
_provider = provider ?? Membership.Provider;
}
#region IMembershipService Members
public int MinPasswordLength
{
get
{
return _provider.MinRequiredPasswordLength;
}
get { return _provider.MinRequiredPasswordLength; }
}
public bool ValidateUser(string userName, string password)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password");
if (String.IsNullOrEmpty(userName))
throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password))
throw new ArgumentException("Value cannot be null or empty.", "password");
return _provider.ValidateUser(userName, password);
}
public MembershipCreateStatus CreateUser(string userName, string password, string email)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password");
if (String.IsNullOrEmpty(userName))
throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password))
throw new ArgumentException("Value cannot be null or empty.", "password");
if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", "email");
MembershipCreateStatus status;
@ -130,9 +134,12 @@ namespace NzbDrone.Web.Models
public bool ChangePassword(string userName, string oldPassword, string newPassword)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(oldPassword)) throw new ArgumentException("Value cannot be null or empty.", "oldPassword");
if (String.IsNullOrEmpty(newPassword)) throw new ArgumentException("Value cannot be null or empty.", "newPassword");
if (String.IsNullOrEmpty(userName))
throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(oldPassword))
throw new ArgumentException("Value cannot be null or empty.", "oldPassword");
if (String.IsNullOrEmpty(newPassword))
throw new ArgumentException("Value cannot be null or empty.", "newPassword");
// The underlying ChangePassword() will throw an exception rather
// than return false in certain failure scenarios.
@ -150,6 +157,8 @@ namespace NzbDrone.Web.Models
return false;
}
}
#endregion
}
public interface IFormsAuthenticationService
@ -160,9 +169,12 @@ namespace NzbDrone.Web.Models
public class FormsAuthenticationService : IFormsAuthenticationService
{
#region IFormsAuthenticationService Members
public void SignIn(string userName, bool createPersistentCookie)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(userName))
throw new ArgumentException("Value cannot be null or empty.", "userName");
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
}
@ -171,10 +183,14 @@ namespace NzbDrone.Web.Models
{
FormsAuthentication.SignOut();
}
#endregion
}
#endregion
#region Validation
public static class AccountValidation
{
public static string ErrorCodeToString(MembershipCreateStatus createStatus)
@ -205,13 +221,16 @@ namespace NzbDrone.Web.Models
return "The user name provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.ProviderError:
return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
return
"The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
case MembershipCreateStatus.UserRejected:
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
return
"The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
return
"An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
}
}
}
@ -234,16 +253,13 @@ namespace NzbDrone.Web.Models
public override object TypeId
{
get
{
return _typeId;
}
get { return _typeId; }
}
public override string FormatErrorMessage(string name)
{
return String.Format(CultureInfo.CurrentUICulture, ErrorMessageString,
OriginalProperty, ConfirmProperty);
OriginalProperty, ConfirmProperty);
}
public override bool IsValid(object value)
@ -251,7 +267,7 @@ namespace NzbDrone.Web.Models
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value);
object originalValue = properties.Find(OriginalProperty, true /* ignoreCase */).GetValue(value);
object confirmValue = properties.Find(ConfirmProperty, true /* ignoreCase */).GetValue(value);
return Object.Equals(originalValue, confirmValue);
return Equals(originalValue, confirmValue);
}
}
@ -269,7 +285,7 @@ namespace NzbDrone.Web.Models
public override string FormatErrorMessage(string name)
{
return String.Format(CultureInfo.CurrentUICulture, ErrorMessageString,
name, _minCharacters);
name, _minCharacters);
}
public override bool IsValid(object value)
@ -278,6 +294,6 @@ namespace NzbDrone.Web.Models
return (valueAsString != null && valueAsString.Length >= _minCharacters);
}
}
#endregion
}
#endregion
}

View file

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.Web.Mvc;
namespace NzbDrone.Web.Models

View file

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
namespace NzbDrone.Web.Models
{
public class AddExistingSeriesModel
{

View file

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Repository;

View file

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;
@ -11,110 +8,63 @@ namespace NzbDrone.Web.Models
{
public class DownloadSettingsModel
{
public SelectList PrioritySelectList =
new SelectList(new[] {"Default", "Paused", "Low", "Normal", "High", "Top"});
[Required]
[Range(15, 120, ErrorMessage = "Must be between 15 and 120 minutes")]
[DataType(DataType.Text)]
[DisplayName("Sync Frequency")]
public int SyncFrequency
{
get;
set;
}
public int SyncFrequency { get; set; }
[DisplayName("Download Propers")]
public bool DownloadPropers
{
get;
set;
}
public bool DownloadPropers { get; set; }
[Required (ErrorMessage = "Please enter a valid number")]
[Required(ErrorMessage = "Please enter a valid number")]
[DataType(DataType.Text)]
[DisplayName("Retention")]
public int Retention
{
get;
set;
}
public int Retention { get; set; }
[Required (ErrorMessage = "Please enter a valid host")]
[Required(ErrorMessage = "Please enter a valid host")]
[DataType(DataType.Text)]
[DisplayName("SABnzbd Host")]
public String SabHost
{
get;
set;
}
public String SabHost { get; set; }
[Required(ErrorMessage = "Please enter a valid port")]
[DataType(DataType.Text)]
[DisplayName("SABnzbd Port")]
public int SabPort
{
get;
set;
}
public int SabPort { get; set; }
[DataType(DataType.Text)]
[DisplayName("SABnzbd API Key")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String SabApiKey
{
get;
set;
}
public String SabApiKey { get; set; }
[DataType(DataType.Text)]
[DisplayName("SABnzbd Username")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String SabUsername
{
get;
set;
}
public String SabUsername { get; set; }
[DataType(DataType.Text)]
[DisplayName("SABnzbd Password")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String SabPassword
{
get;
set;
}
public String SabPassword { get; set; }
[DataType(DataType.Text)]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[DisplayName("SABnzbd TV Category")]
public String SabTvCategory
{
get;
set;
}
public String SabTvCategory { get; set; }
[Required(ErrorMessage = "Please select a valid priority")]
[DisplayName("SABnzbd Priority")]
public SabnzbdPriorityType SabTvPriority
{
get;
set;
}
public SabnzbdPriorityType SabTvPriority { get; set; }
[DisplayName("Use Blackhole")]
public bool UseBlackHole
{
get;
set;
}
public bool UseBlackHole { get; set; }
[DataType(DataType.Text)]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[DisplayName("Blackhole Directory")]
public String BlackholeDirectory
{
get;
set;
}
public SelectList PrioritySelectList = new SelectList(new string[] { "Default", "Paused", "Low", "Normal", "High", "Top" });
public String BlackholeDirectory { get; set; }
}
}

View file

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Models
{

View file

@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;
namespace NzbDrone.Web.Models
{

View file

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Models
{

View file

@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository;
namespace NzbDrone.Web.Models
@ -13,61 +11,33 @@ namespace NzbDrone.Web.Models
[DataType(DataType.Text)]
[DisplayName("NZBMatrix Username")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbMatrixUsername
{
get;
set;
}
public String NzbMatrixUsername { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBMatrix API Key")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbMatrixApiKey
{
get;
set;
}
public String NzbMatrixApiKey { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBs.Org UID")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsOrgUId
{
get;
set;
}
public String NzbsOrgUId { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBs.Org Hash")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsOrgHash
{
get;
set;
}
public String NzbsOrgHash { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBsRus UID")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsrusUId
{
get;
set;
}
public String NzbsrusUId { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBsRus Hash")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsrusHash
{
get;
set;
}
public String NzbsrusHash { get; set; }
public List<Indexer> Indexers
{
get;
set;
}
public List<Indexer> Indexers { get; set; }
}
}

View file

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Models
{

View file

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
{

View file

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Repository.Quality;

View file

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
{

View file

@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
namespace NzbDrone.Web.Models
{
public class SettingsModel
{
[DisplayName("TV Series Root Folder(s)")]
public List<RootDir> Directories { get; set; }
}
}
}

View file

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
namespace NzbDrone.Web.Models
{
public class TestModel
{

View file

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
{