1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-17 15:02:34 +02:00

removed redundant qualifiers.

This commit is contained in:
kay.one 2013-07-23 22:35:32 -07:00
parent 50f66cbcca
commit e89a35522e
35 changed files with 128 additions and 106 deletions

View File

@ -14,10 +14,12 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */ License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System; using System;
using System.Globalization;
using Marr.Data.Mapping;
namespace Marr.Data.Converters namespace Marr.Data.Converters
{ {
public class CastConverter<TClr, TDb> : Marr.Data.Converters.IConverter public class CastConverter<TClr, TDb> : IConverter
where TClr : IConvertible where TClr : IConvertible
where TDb : IConvertible where TDb : IConvertible
{ {
@ -28,16 +30,16 @@ public Type DbType
get { return typeof(TDb); } get { return typeof(TDb); }
} }
public object FromDB(Marr.Data.Mapping.ColumnMap map, object dbValue) public object FromDB(ColumnMap map, object dbValue)
{ {
TDb val = (TDb)dbValue; TDb val = (TDb)dbValue;
return val.ToType(typeof(TClr), System.Globalization.CultureInfo.InvariantCulture); return val.ToType(typeof(TClr), CultureInfo.InvariantCulture);
} }
public object ToDB(object clrValue) public object ToDB(object clrValue)
{ {
TClr val = (TClr)clrValue; TClr val = (TClr)clrValue;
return val.ToType(typeof(TDb), System.Globalization.CultureInfo.InvariantCulture); return val.ToType(typeof(TDb), CultureInfo.InvariantCulture);
} }
#endregion #endregion

View File

@ -131,7 +131,7 @@ public IDbDataParameter AddParameter(IDbDataParameter parameter)
if (parameter.Value == null) if (parameter.Value == null)
parameter.Value = DBNull.Value; parameter.Value = DBNull.Value;
this.Parameters.Add(parameter); Parameters.Add(parameter);
return parameter; return parameter;
} }
@ -395,7 +395,7 @@ public int UpdateDataSet(DataSet ds, string sql)
public int InsertDataTable(DataTable table, string insertSP) public int InsertDataTable(DataTable table, string insertSP)
{ {
return this.InsertDataTable(table, insertSP, UpdateRowSource.None); return InsertDataTable(table, insertSP, UpdateRowSource.None);
} }
public int InsertDataTable(DataTable dt, string sql, UpdateRowSource updateRowSource) public int InsertDataTable(DataTable dt, string sql, UpdateRowSource updateRowSource)
@ -462,7 +462,7 @@ public int DeleteDataTable(DataTable dt, string sql)
public T Find<T>(string sql) public T Find<T>(string sql)
{ {
return this.Find<T>(sql, default(T)); return Find<T>(sql, default(T));
} }
/// <summary> /// <summary>
@ -526,7 +526,7 @@ public T Find<T>(string sql, T ent)
/// <returns>Returns a QueryBuilder of T.</returns> /// <returns>Returns a QueryBuilder of T.</returns>
public QueryBuilder<T> Query<T>() public QueryBuilder<T> Query<T>()
{ {
var dialect = QGen.QueryFactory.CreateDialect(this); var dialect = QueryFactory.CreateDialect(this);
return new QueryBuilder<T>(this, dialect); return new QueryBuilder<T>(this, dialect);
} }
@ -783,7 +783,7 @@ public int Delete<T>(Expression<Func<T, bool>> filter)
public int Delete<T>(string tableName, Expression<Func<T, bool>> filter) public int Delete<T>(string tableName, Expression<Func<T, bool>> filter)
{ {
// Remember sql mode // Remember sql mode
var previousSqlMode = this.SqlMode; var previousSqlMode = SqlMode;
SqlMode = SqlModes.Text; SqlMode = SqlModes.Text;
var mappingHelper = new MappingHelper(this); var mappingHelper = new MappingHelper(this);
@ -791,7 +791,7 @@ public int Delete<T>(string tableName, Expression<Func<T, bool>> filter)
{ {
tableName = MapRepository.Instance.GetTableName(typeof(T)); tableName = MapRepository.Instance.GetTableName(typeof(T));
} }
var dialect = QGen.QueryFactory.CreateDialect(this); var dialect = QueryFactory.CreateDialect(this);
TableCollection tables = new TableCollection(); TableCollection tables = new TableCollection();
tables.Add(new Table(typeof(T))); tables.Add(new Table(typeof(T)));
var where = new WhereBuilder<T>(Command, dialect, filter, tables, false, false); var where = new WhereBuilder<T>(Command, dialect, filter, tables, false, false);

View File

@ -84,7 +84,7 @@ private EntityGraph(Type entityType, EntityGraph parent, Relationship relationsh
} }
// Create a new EntityGraph for each child relationship that is not lazy loaded // Create a new EntityGraph for each child relationship that is not lazy loaded
foreach (Relationship childRelationship in this.Relationships) foreach (Relationship childRelationship in Relationships)
{ {
if (!childRelationship.IsLazyLoaded) if (!childRelationship.IsLazyLoaded)
{ {
@ -169,7 +169,7 @@ public void AddEntity(object entityInstance)
_entity = entityInstance; _entity = entityInstance;
// Add newly created entityInstance to list (Many) or set it to field (One) // Add newly created entityInstance to list (Many) or set it to field (One)
if (this.IsRoot) if (IsRoot)
{ {
RootList.Add(entityInstance); RootList.Add(entityInstance);
} }
@ -213,7 +213,7 @@ public bool IsNewGroup(DbDataReader reader)
bool isNewGroup = false; bool isNewGroup = false;
// Get primary keys from parent entity and any one-to-one child entites // Get primary keys from parent entity and any one-to-one child entites
GroupingKeyCollection groupingKeyColumns = this.GroupingKeyColumns; GroupingKeyCollection groupingKeyColumns = GroupingKeyColumns;
// Concatenate column values // Concatenate column values
KeyGroupInfo keyGroupInfo = groupingKeyColumns.CreateGroupingKey(reader); KeyGroupInfo keyGroupInfo = groupingKeyColumns.CreateGroupingKey(reader);
@ -265,7 +265,7 @@ private bool AnyParentsAreOfType(Type type)
private object FindParentReference() private object FindParentReference()
{ {
var parent = this.Parent.Parent; var parent = Parent.Parent;
while (parent != null) while (parent != null)
{ {
if (parent._entityType == _relationship.MemberType) if (parent._entityType == _relationship.MemberType)
@ -333,7 +333,7 @@ private GroupingKeyCollection GetGroupingKeyColumns()
// * Only 1-1 entities with no children are allowed to have 0 PKs specified. // * Only 1-1 entities with no children are allowed to have 0 PKs specified.
if ((groupingKeyColumns.PrimaryKeys.Count == 0 && _children.Count > 0) || if ((groupingKeyColumns.PrimaryKeys.Count == 0 && _children.Count > 0) ||
(groupingKeyColumns.PrimaryKeys.Count == 0 && !IsRoot && _relationship.RelationshipInfo.RelationType == RelationshipTypes.Many)) (groupingKeyColumns.PrimaryKeys.Count == 0 && !IsRoot && _relationship.RelationshipInfo.RelationType == RelationshipTypes.Many))
throw new MissingPrimaryKeyException(string.Format("There are no primary key mappings defined for the following entity: '{0}'.", this.EntityType.Name)); throw new MissingPrimaryKeyException(string.Format("There are no primary key mappings defined for the following entity: '{0}'.", EntityType.Name));
// Add parent's keys // Add parent's keys
if (IsChild) if (IsChild)
@ -378,7 +378,7 @@ private static IEnumerator<EntityGraph> TraverseGraph(EntityGraph entityGraph)
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
return this.GetEnumerator(); return GetEnumerator();
} }
#endregion #endregion

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using Marr.Data.Mapping; using Marr.Data.Mapping;
@ -74,9 +75,9 @@ public IEnumerator<ColumnMap> GetEnumerator()
#region IEnumerable Members #region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
return this.GetEnumerator(); return GetEnumerator();
} }
#endregion #endregion

View File

@ -53,10 +53,10 @@ private MapRepository()
ReflectionStrategy = new SimpleReflectionStrategy(); ReflectionStrategy = new SimpleReflectionStrategy();
// Register a default type converter for Enums // Register a default type converter for Enums
TypeConverters.Add(typeof(Enum), new Converters.EnumStringConverter()); TypeConverters.Add(typeof(Enum), new EnumStringConverter());
// Register a default IDbTypeBuilder // Register a default IDbTypeBuilder
_dbTypeBuilder = new Parameters.DbTypeBuilder(); _dbTypeBuilder = new DbTypeBuilder();
_columnMapStrategies = new Dictionary<Type, IMapStrategy>(); _columnMapStrategies = new Dictionary<Type, IMapStrategy>();
RegisterDefaultMapStrategy(new AttributeMapStrategy()); RegisterDefaultMapStrategy(new AttributeMapStrategy());

View File

@ -1,4 +1,6 @@
namespace Marr.Data.Mapping using System.Data;
namespace Marr.Data.Mapping
{ {
public class ColumnInfo : IColumnInfo public class ColumnInfo : IColumnInfo
{ {
@ -7,7 +9,7 @@ public ColumnInfo()
IsPrimaryKey = false; IsPrimaryKey = false;
IsAutoIncrement = false; IsAutoIncrement = false;
ReturnValue = false; ReturnValue = false;
ParamDirection = System.Data.ParameterDirection.Input; ParamDirection = ParameterDirection.Input;
} }
public string Name { get; set; } public string Name { get; set; }
@ -16,7 +18,7 @@ public ColumnInfo()
public bool IsPrimaryKey { get; set; } public bool IsPrimaryKey { get; set; }
public bool IsAutoIncrement { get; set; } public bool IsAutoIncrement { get; set; }
public bool ReturnValue { get; set; } public bool ReturnValue { get; set; }
public System.Data.ParameterDirection ParamDirection { get; set; } public ParameterDirection ParamDirection { get; set; }
public string TryGetAltName() public string TryGetAltName()
{ {

View File

@ -30,12 +30,12 @@ public class ColumnMapCollection : List<ColumnMap>
public ColumnMap GetByColumnName(string columnName) public ColumnMap GetByColumnName(string columnName)
{ {
return this.Find(m => m.ColumnInfo.Name == columnName); return Find(m => m.ColumnInfo.Name == columnName);
} }
public ColumnMap GetByFieldName(string fieldName) public ColumnMap GetByFieldName(string fieldName)
{ {
return this.Find(m => m.FieldName == fieldName); return Find(m => m.FieldName == fieldName);
} }
/// <summary> /// <summary>
@ -107,7 +107,7 @@ public ColumnMapCollection PrimaryKeys
/// <returns>A list of mapped columns that are present in the sql statement as parameters.</returns> /// <returns>A list of mapped columns that are present in the sql statement as parameters.</returns>
public ColumnMapCollection OrderParameters(DbCommand command) public ColumnMapCollection OrderParameters(DbCommand command)
{ {
if (command.CommandType == CommandType.Text && this.Count > 0) if (command.CommandType == CommandType.Text && Count > 0)
{ {
string commandTypeString = command.GetType().ToString(); string commandTypeString = command.GetType().ToString();
if (commandTypeString.Contains("Oracle") || commandTypeString.Contains("OleDb")) if (commandTypeString.Contains("Oracle") || commandTypeString.Contains("OleDb"))
@ -120,7 +120,7 @@ public ColumnMapCollection OrderParameters(DbCommand command)
Regex regex = new Regex(regexString); Regex regex = new Regex(regexString);
foreach (Match m in regex.Matches(command.CommandText)) foreach (Match m in regex.Matches(command.CommandText))
{ {
ColumnMap matchingColumn = this.Find(c => string.Concat(paramPrefix, c.ColumnInfo.Name.ToLower()) == m.Value.ToLower()); ColumnMap matchingColumn = Find(c => string.Concat(paramPrefix, c.ColumnInfo.Name.ToLower()) == m.Value.ToLower());
if (matchingColumn != null) if (matchingColumn != null)
columns.Add(matchingColumn); columns.Add(matchingColumn);
} }
@ -148,7 +148,7 @@ public ColumnMapCollection OrderParameters(DbCommand command)
/// <returns></returns> /// <returns></returns>
public ColumnMapCollection PrefixAltNames(string prefix) public ColumnMapCollection PrefixAltNames(string prefix)
{ {
this.ForEach(c => c.ColumnInfo.AltName = c.ColumnInfo.Name.Insert(0, prefix)); ForEach(c => c.ColumnInfo.AltName = c.ColumnInfo.Name.Insert(0, prefix));
return this; return this;
} }
@ -163,7 +163,7 @@ public ColumnMapCollection PrefixAltNames(string prefix)
/// <returns></returns> /// <returns></returns>
public ColumnMapCollection SuffixAltNames(string suffix) public ColumnMapCollection SuffixAltNames(string suffix)
{ {
this.ForEach(c => c.ColumnInfo.AltName = c.ColumnInfo.Name + suffix); ForEach(c => c.ColumnInfo.AltName = c.ColumnInfo.Name + suffix);
return this; return this;
} }

View File

@ -55,9 +55,9 @@ public MappingsFluentEntity(bool publicOnly)
public class MappingsFluentColumns<TEntity> public class MappingsFluentColumns<TEntity>
{ {
private bool _publicOnly; private bool _publicOnly;
private FluentMappings.MappingsFluentEntity<TEntity> _fluentEntity; private MappingsFluentEntity<TEntity> _fluentEntity;
public MappingsFluentColumns(FluentMappings.MappingsFluentEntity<TEntity> fluentEntity, bool publicOnly) public MappingsFluentColumns(MappingsFluentEntity<TEntity> fluentEntity, bool publicOnly)
{ {
_fluentEntity = fluentEntity; _fluentEntity = fluentEntity;
_publicOnly = publicOnly; _publicOnly = publicOnly;
@ -122,9 +122,9 @@ public ColumnMapBuilder<TEntity> MapProperties()
public class MappingsFluentTables<TEntity> public class MappingsFluentTables<TEntity>
{ {
private FluentMappings.MappingsFluentEntity<TEntity> _fluentEntity; private MappingsFluentEntity<TEntity> _fluentEntity;
public MappingsFluentTables(FluentMappings.MappingsFluentEntity<TEntity> fluentEntity) public MappingsFluentTables(MappingsFluentEntity<TEntity> fluentEntity)
{ {
_fluentEntity = fluentEntity; _fluentEntity = fluentEntity;
} }
@ -152,10 +152,10 @@ public TableBuilder<TEntity> MapTable(string tableName)
public class MappingsFluentRelationships<TEntity> public class MappingsFluentRelationships<TEntity>
{ {
private FluentMappings.MappingsFluentEntity<TEntity> _fluentEntity; private MappingsFluentEntity<TEntity> _fluentEntity;
private bool _publicOnly; private bool _publicOnly;
public MappingsFluentRelationships(FluentMappings.MappingsFluentEntity<TEntity> fluentEntity, bool publicOnly) public MappingsFluentRelationships(MappingsFluentEntity<TEntity> fluentEntity, bool publicOnly)
{ {
_fluentEntity = fluentEntity; _fluentEntity = fluentEntity;
_publicOnly = publicOnly; _publicOnly = publicOnly;

View File

@ -14,6 +14,7 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */ License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System; using System;
using System.Collections;
using System.Reflection; using System.Reflection;
using Marr.Data.Reflection; using Marr.Data.Reflection;
@ -35,7 +36,7 @@ public Relationship(MemberInfo member, IRelationshipInfo relationshipInfo)
// Try to determine the RelationshipType // Try to determine the RelationshipType
if (relationshipInfo.RelationType == RelationshipTypes.AutoDetect) if (relationshipInfo.RelationType == RelationshipTypes.AutoDetect)
{ {
if (typeof(System.Collections.ICollection).IsAssignableFrom(MemberType)) if (typeof(ICollection).IsAssignableFrom(MemberType))
{ {
relationshipInfo.RelationType = RelationshipTypes.Many; relationshipInfo.RelationType = RelationshipTypes.Many;
} }

View File

@ -28,7 +28,7 @@ public Relationship this[string fieldName]
{ {
get get
{ {
return this.Find(m => m.Member.Name == fieldName); return Find(m => m.Member.Name == fieldName);
} }
} }
} }

View File

@ -27,7 +27,7 @@ public ConventionMapStrategy(bool publicOnly)
protected override void CreateColumnMap(Type entityType, System.Reflection.MemberInfo member, ColumnAttribute columnAtt, ColumnMapCollection columnMaps) protected override void CreateColumnMap(Type entityType, MemberInfo member, ColumnAttribute columnAtt, ColumnMapCollection columnMaps)
{ {
if (ColumnPredicate(member)) if (ColumnPredicate(member))
{ {
@ -36,7 +36,7 @@ protected override void CreateColumnMap(Type entityType, System.Reflection.Membe
} }
} }
protected override void CreateRelationship(Type entityType, System.Reflection.MemberInfo member, RelationshipAttribute relationshipAtt, RelationshipCollection relationships) protected override void CreateRelationship(Type entityType, MemberInfo member, RelationshipAttribute relationshipAtt, RelationshipCollection relationships)
{ {
if (RelationshipPredicate(member)) if (RelationshipPredicate(member))
{ {

View File

@ -14,6 +14,7 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */ License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System; using System;
using System.Collections;
using System.Reflection; using System.Reflection;
namespace Marr.Data.Mapping.Strategies namespace Marr.Data.Mapping.Strategies
@ -70,7 +71,7 @@ protected override void CreateRelationship(Type entityType, MemberInfo member, R
if (member.MemberType == MemberTypes.Property) if (member.MemberType == MemberTypes.Property)
{ {
PropertyInfo propertyInfo = member as PropertyInfo; PropertyInfo propertyInfo = member as PropertyInfo;
if (typeof(System.Collections.ICollection).IsAssignableFrom(propertyInfo.PropertyType)) if (typeof(ICollection).IsAssignableFrom(propertyInfo.PropertyType))
{ {
Relationship relationship = new Relationship(member); Relationship relationship = new Relationship(member);
relationships.Add(relationship); relationships.Add(relationship);

View File

@ -62,7 +62,7 @@ public Enum GetDbType(Type type)
return DbType.Object; return DbType.Object;
} }
public void SetDbType(System.Data.IDbDataParameter param, Enum dbType) public void SetDbType(IDbDataParameter param, Enum dbType)
{ {
param.DbType = (DbType)dbType; param.DbType = (DbType)dbType;
} }

View File

@ -14,6 +14,7 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */ License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System; using System;
using System.Data;
using System.Data.OleDb; using System.Data.OleDb;
namespace Marr.Data.Parameters namespace Marr.Data.Parameters
@ -59,7 +60,7 @@ public Enum GetDbType(Type type)
return OleDbType.Variant; return OleDbType.Variant;
} }
public void SetDbType(System.Data.IDbDataParameter param, Enum dbType) public void SetDbType(IDbDataParameter param, Enum dbType)
{ {
var oleDbParam = (OleDbParameter)param; var oleDbParam = (OleDbParameter)param;
oleDbParam.OleDbType = (OleDbType)dbType; oleDbParam.OleDbType = (OleDbType)dbType;

View File

@ -63,7 +63,7 @@ public Enum GetDbType(Type type)
return SqlDbType.Variant; return SqlDbType.Variant;
} }
public void SetDbType(System.Data.IDbDataParameter param, Enum dbType) public void SetDbType(IDbDataParameter param, Enum dbType)
{ {
var sqlDbParam = (SqlParameter)param; var sqlDbParam = (SqlParameter)param;
sqlDbParam.SqlDbType = (SqlDbType)dbType; sqlDbParam.SqlDbType = (SqlDbType)dbType;

View File

@ -1,4 +1,6 @@
namespace Marr.Data.QGen using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen
{ {
/// <summary> /// <summary>
/// This class creates a SQL delete query. /// This class creates a SQL delete query.
@ -7,9 +9,9 @@ public class DeleteQuery : IQuery
{ {
protected Table TargetTable { get; set; } protected Table TargetTable { get; set; }
protected string WhereClause { get; set; } protected string WhereClause { get; set; }
protected Dialects.Dialect Dialect { get; set; } protected Dialect Dialect { get; set; }
public DeleteQuery(Dialects.Dialect dialect, Table targetTable, string whereClause) public DeleteQuery(Dialect dialect, Table targetTable, string whereClause)
{ {
Dialect = dialect; Dialect = dialect;
TargetTable = targetTable; TargetTable = targetTable;

View File

@ -35,7 +35,7 @@ protected virtual Expression Visit(Expression expression)
case ExpressionType.Not: case ExpressionType.Not:
case ExpressionType.Quote: case ExpressionType.Quote:
case ExpressionType.TypeAs: case ExpressionType.TypeAs:
return this.VisitUnary((UnaryExpression)expression); return VisitUnary((UnaryExpression)expression);
case ExpressionType.Add: case ExpressionType.Add:
case ExpressionType.AddChecked: case ExpressionType.AddChecked:
case ExpressionType.And: case ExpressionType.And:
@ -60,15 +60,15 @@ protected virtual Expression Visit(Expression expression)
case ExpressionType.RightShift: case ExpressionType.RightShift:
case ExpressionType.Subtract: case ExpressionType.Subtract:
case ExpressionType.SubtractChecked: case ExpressionType.SubtractChecked:
return this.VisitBinary((BinaryExpression)expression); return VisitBinary((BinaryExpression)expression);
case ExpressionType.Call: case ExpressionType.Call:
return this.VisitMethodCall((MethodCallExpression)expression); return VisitMethodCall((MethodCallExpression)expression);
case ExpressionType.Constant: case ExpressionType.Constant:
return this.VisitConstant((ConstantExpression)expression); return VisitConstant((ConstantExpression)expression);
case ExpressionType.MemberAccess: case ExpressionType.MemberAccess:
return this.VisitMemberAccess((MemberExpression)expression); return VisitMemberAccess((MemberExpression)expression);
case ExpressionType.Parameter: case ExpressionType.Parameter:
return this.VisitParameter((ParameterExpression)expression); return VisitParameter((ParameterExpression)expression);
} }
throw new ArgumentOutOfRangeException("expression", expression.NodeType.ToString()); throw new ArgumentOutOfRangeException("expression", expression.NodeType.ToString());
@ -111,8 +111,8 @@ protected virtual Expression VisitMethodCall(MethodCallExpression expression)
/// <returns></returns> /// <returns></returns>
protected virtual Expression VisitBinary(BinaryExpression expression) protected virtual Expression VisitBinary(BinaryExpression expression)
{ {
this.Visit(expression.Left); Visit(expression.Left);
this.Visit(expression.Right); Visit(expression.Right);
return expression; return expression;
} }
@ -123,7 +123,7 @@ protected virtual Expression VisitBinary(BinaryExpression expression)
/// <returns></returns> /// <returns></returns>
protected virtual Expression VisitUnary(UnaryExpression expression) protected virtual Expression VisitUnary(UnaryExpression expression)
{ {
this.Visit(expression.Operand); Visit(expression.Operand);
return expression; return expression;
} }
@ -134,7 +134,7 @@ protected virtual Expression VisitUnary(UnaryExpression expression)
/// <returns></returns> /// <returns></returns>
protected virtual Expression VisitLamda(LambdaExpression lambdaExpression) protected virtual Expression VisitLamda(LambdaExpression lambdaExpression)
{ {
this.Visit(lambdaExpression.Body); Visit(lambdaExpression.Body);
return lambdaExpression; return lambdaExpression;
} }

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Marr.Data.Mapping; using Marr.Data.Mapping;
using System.Linq.Expressions; using System.Linq.Expressions;
using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen namespace Marr.Data.QGen
{ {
@ -15,7 +16,7 @@ public class InsertQueryBuilder<T> : IQueryBuilder
private SqlModes _previousSqlMode; private SqlModes _previousSqlMode;
private bool _generateQuery = true; private bool _generateQuery = true;
private bool _getIdentityValue; private bool _getIdentityValue;
private Dialects.Dialect _dialect; private Dialect _dialect;
private ColumnMapCollection _columnsToInsert; private ColumnMapCollection _columnsToInsert;
public InsertQueryBuilder() public InsertQueryBuilder()

View File

@ -6,6 +6,7 @@
using Marr.Data.Mapping; using Marr.Data.Mapping;
using System.Data.Common; using System.Data.Common;
using System.Collections; using System.Collections;
using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen namespace Marr.Data.QGen
{ {
@ -19,7 +20,7 @@ public class QueryBuilder<T> : ExpressionVisitor, IEnumerable<T>, IQueryBuilder
#region - Private Members - #region - Private Members -
private DataMapper _db; private DataMapper _db;
private Dialects.Dialect _dialect; private Dialect _dialect;
private TableCollection _tables; private TableCollection _tables;
private WhereBuilder<T> _whereBuilder; private WhereBuilder<T> _whereBuilder;
private SortBuilder<T> _sortBuilder; private SortBuilder<T> _sortBuilder;
@ -71,7 +72,7 @@ public QueryBuilder()
// Used only for unit testing with mock frameworks // Used only for unit testing with mock frameworks
} }
public QueryBuilder(DataMapper db, Dialects.Dialect dialect) public QueryBuilder(DataMapper db, Dialect dialect)
{ {
_db = db; _db = db;
_dialect = dialect; _dialect = dialect;
@ -499,7 +500,7 @@ public virtual QueryBuilder<T> Skip(int count)
/// </summary> /// </summary>
/// <param name="expression"></param> /// <param name="expression"></param>
/// <returns></returns> /// <returns></returns>
protected override System.Linq.Expressions.Expression Visit(System.Linq.Expressions.Expression expression) protected override Expression Visit(Expression expression)
{ {
return base.Visit(expression); return base.Visit(expression);
} }
@ -509,9 +510,9 @@ protected override System.Linq.Expressions.Expression Visit(System.Linq.Expressi
/// </summary> /// </summary>
/// <param name="lambdaExpression"></param> /// <param name="lambdaExpression"></param>
/// <returns></returns> /// <returns></returns>
protected override System.Linq.Expressions.Expression VisitLamda(System.Linq.Expressions.LambdaExpression lambdaExpression) protected override Expression VisitLamda(LambdaExpression lambdaExpression)
{ {
_sortBuilder = this.Where(lambdaExpression as Expression<Func<T, bool>>); _sortBuilder = Where(lambdaExpression as Expression<Func<T, bool>>);
return base.VisitLamda(lambdaExpression); return base.VisitLamda(lambdaExpression);
} }
@ -520,16 +521,16 @@ protected override System.Linq.Expressions.Expression VisitLamda(System.Linq.Exp
/// </summary> /// </summary>
/// <param name="expression"></param> /// <param name="expression"></param>
/// <returns></returns> /// <returns></returns>
protected override System.Linq.Expressions.Expression VisitMethodCall(MethodCallExpression expression) protected override Expression VisitMethodCall(MethodCallExpression expression)
{ {
if (expression.Method.Name == "OrderBy" || expression.Method.Name == "ThenBy") if (expression.Method.Name == "OrderBy" || expression.Method.Name == "ThenBy")
{ {
var memberExp = ((expression.Arguments[1] as UnaryExpression).Operand as System.Linq.Expressions.LambdaExpression).Body as System.Linq.Expressions.MemberExpression; var memberExp = ((expression.Arguments[1] as UnaryExpression).Operand as LambdaExpression).Body as MemberExpression;
_sortBuilder.Order(memberExp.Expression.Type, memberExp.Member.Name); _sortBuilder.Order(memberExp.Expression.Type, memberExp.Member.Name);
} }
if (expression.Method.Name == "OrderByDescending" || expression.Method.Name == "ThenByDescending") if (expression.Method.Name == "OrderByDescending" || expression.Method.Name == "ThenByDescending")
{ {
var memberExp = ((expression.Arguments[1] as UnaryExpression).Operand as System.Linq.Expressions.LambdaExpression).Body as System.Linq.Expressions.MemberExpression; var memberExp = ((expression.Arguments[1] as UnaryExpression).Operand as LambdaExpression).Body as MemberExpression;
_sortBuilder.OrderByDescending(memberExp.Expression.Type, memberExp.Member.Name); _sortBuilder.OrderByDescending(memberExp.Expression.Type, memberExp.Member.Name);
} }
@ -540,14 +541,14 @@ public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, Expression
{ {
_isJoin = true; _isJoin = true;
MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member; MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member;
return this.Join(joinType, rightMember, filterExpression); return Join(joinType, rightMember, filterExpression);
} }
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, Expression<Func<TLeft, TRight>> rightEntity, Expression<Func<TLeft, TRight, bool>> filterExpression) public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, Expression<Func<TLeft, TRight>> rightEntity, Expression<Func<TLeft, TRight, bool>> filterExpression)
{ {
_isJoin = true; _isJoin = true;
MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member; MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member;
return this.Join(joinType, rightMember, filterExpression); return Join(joinType, rightMember, filterExpression);
} }
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, MemberInfo rightMember, Expression<Func<TLeft, TRight, bool>> filterExpression) public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, MemberInfo rightMember, Expression<Func<TLeft, TRight, bool>> filterExpression)
@ -598,7 +599,7 @@ public virtual bool Any()
IEnumerator<T> IEnumerable<T>.GetEnumerator() IEnumerator<T> IEnumerable<T>.GetEnumerator()
{ {
var list = this.ToList(); var list = ToList();
return list.GetEnumerator(); return list.GetEnumerator();
} }
@ -608,7 +609,7 @@ IEnumerator<T> IEnumerable<T>.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
var list = this.ToList(); var list = ToList();
return list.GetEnumerator(); return list.GetEnumerator();
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using Marr.Data.Mapping;
using Marr.Data.QGen.Dialects; using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen namespace Marr.Data.QGen
@ -16,19 +17,19 @@ internal class QueryFactory
private const string DB_FireBirdClient = "FirebirdSql.Data.FirebirdClient.FirebirdClientFactory"; private const string DB_FireBirdClient = "FirebirdSql.Data.FirebirdClient.FirebirdClientFactory";
private const string DB_SQLiteClient = "System.Data.SQLite.SQLiteFactory"; private const string DB_SQLiteClient = "System.Data.SQLite.SQLiteFactory";
public static IQuery CreateUpdateQuery(Mapping.ColumnMapCollection columns, IDataMapper dataMapper, string target, string whereClause) public static IQuery CreateUpdateQuery(ColumnMapCollection columns, IDataMapper dataMapper, string target, string whereClause)
{ {
Dialect dialect = CreateDialect(dataMapper); Dialect dialect = CreateDialect(dataMapper);
return new UpdateQuery(dialect, columns, dataMapper.Command, target, whereClause); return new UpdateQuery(dialect, columns, dataMapper.Command, target, whereClause);
} }
public static IQuery CreateInsertQuery(Mapping.ColumnMapCollection columns, IDataMapper dataMapper, string target) public static IQuery CreateInsertQuery(ColumnMapCollection columns, IDataMapper dataMapper, string target)
{ {
Dialect dialect = CreateDialect(dataMapper); Dialect dialect = CreateDialect(dataMapper);
return new InsertQuery(dialect, columns, dataMapper.Command, target); return new InsertQuery(dialect, columns, dataMapper.Command, target);
} }
public static IQuery CreateDeleteQuery(Dialects.Dialect dialect, Table targetTable, string whereClause) public static IQuery CreateDeleteQuery(Dialect dialect, Table targetTable, string whereClause)
{ {
return new DeleteQuery(dialect, targetTable, whereClause); return new DeleteQuery(dialect, targetTable, whereClause);
} }
@ -81,7 +82,7 @@ public static IQuery CreatePagingSelectQuery(TableCollection tables, IDataMapper
} }
} }
public static Dialects.Dialect CreateDialect(IDataMapper dataMapper) public static Dialect CreateDialect(IDataMapper dataMapper)
{ {
string providerString = dataMapper.ProviderFactory.ToString(); string providerString = dataMapper.ProviderFactory.ToString();
switch (providerString) switch (providerString)

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Linq.Expressions; using System.Linq.Expressions;
@ -243,7 +244,7 @@ public static implicit operator List<T>(SortBuilder<T> builder)
public virtual IEnumerator<T> GetEnumerator() public virtual IEnumerator<T> GetEnumerator()
{ {
var list = this.ToList(); var list = ToList();
return list.GetEnumerator(); return list.GetEnumerator();
} }
@ -251,7 +252,7 @@ public virtual IEnumerator<T> GetEnumerator()
#region IEnumerable Members #region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -41,7 +41,7 @@ public void ReplaceBaseTable(View view)
/// </summary> /// </summary>
public Table FindTable(Type declaringType) public Table FindTable(Type declaringType)
{ {
return this.EnumerateViewsAndTables().Where(t => t.EntityType == declaringType).FirstOrDefault(); return EnumerateViewsAndTables().Where(t => t.EntityType == declaringType).FirstOrDefault();
} }
public Table this[int index] public Table this[int index]

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Marr.Data.Mapping; using Marr.Data.Mapping;
using System.Linq.Expressions; using System.Linq.Expressions;
using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen namespace Marr.Data.QGen
{ {
@ -16,7 +17,7 @@ public class UpdateQueryBuilder<T>
private bool _generateQuery = true; private bool _generateQuery = true;
private TableCollection _tables; private TableCollection _tables;
private Expression<Func<T, bool>> _filterExpression; private Expression<Func<T, bool>> _filterExpression;
private Dialects.Dialect _dialect; private Dialect _dialect;
private ColumnMapCollection _columnsToUpdate; private ColumnMapCollection _columnsToUpdate;
public UpdateQueryBuilder() public UpdateQueryBuilder()

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Marr.Data.Mapping; using Marr.Data.Mapping;
@ -11,7 +12,7 @@ public class View : Table, IEnumerable<Table>
{ {
private string _viewName; private string _viewName;
private Table[] _tables; private Table[] _tables;
private Mapping.ColumnMapCollection _columns; private ColumnMapCollection _columns;
public View(string viewName, Table[] tables) public View(string viewName, Table[] tables)
: base(tables[0].EntityType, JoinType.None) : base(tables[0].EntityType, JoinType.None)
@ -58,7 +59,7 @@ public override string Alias
/// <summary> /// <summary>
/// Gets all the columns from all the tables included in the view. /// Gets all the columns from all the tables included in the view.
/// </summary> /// </summary>
public override Mapping.ColumnMapCollection Columns public override ColumnMapCollection Columns
{ {
get get
{ {
@ -81,9 +82,9 @@ public IEnumerator<Table> GetEnumerator()
} }
} }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
return this.GetEnumerator(); return GetEnumerator();
} }
} }
} }

View File

@ -78,7 +78,7 @@ protected override Expression VisitBinary(BinaryExpression expression)
protected override Expression VisitMethodCall(MethodCallExpression expression) protected override Expression VisitMethodCall(MethodCallExpression expression)
{ {
string method = (expression as System.Linq.Expressions.MethodCallExpression).Method.Name; string method = (expression as MethodCallExpression).Method.Name;
switch (method) switch (method)
{ {
case "Contains": case "Contains":
@ -270,7 +270,7 @@ private void Write_EndsWith(MethodCallExpression body)
internal void Append(WhereBuilder<T> where, WhereAppendType appendType) internal void Append(WhereBuilder<T> where, WhereAppendType appendType)
{ {
_constantWhereClause = string.Format("{0} {1} {2}", _constantWhereClause = string.Format("{0} {1} {2}",
this.ToString(), ToString(),
appendType.ToString(), appendType.ToString(),
where.ToString().Replace("WHERE ", string.Empty)); where.ToString().Replace("WHERE ", string.Empty));
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Runtime.Serialization;
namespace Marr.Data namespace Marr.Data
{ {
@ -118,8 +119,8 @@ public NestedSharedContextRollBackException() { }
public NestedSharedContextRollBackException(string message) : base(message) { } public NestedSharedContextRollBackException(string message) : base(message) { }
public NestedSharedContextRollBackException(string message, Exception inner) : base(message, inner) { } public NestedSharedContextRollBackException(string message, Exception inner) : base(message, inner) { }
protected NestedSharedContextRollBackException( protected NestedSharedContextRollBackException(
System.Runtime.Serialization.SerializationInfo info, SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) StreamingContext context)
: base(info, context) { } : base(info, context) { }
} }
} }

View File

@ -21,6 +21,7 @@
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.RootFolders; using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Update; using NzbDrone.Core.Update;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using System.Linq; using System.Linq;
@ -31,7 +32,7 @@ namespace NzbDrone.Api.Test.MappingTests
public class ResourceMappingFixture : TestBase public class ResourceMappingFixture : TestBase
{ {
[TestCase(typeof(Core.Tv.Series), typeof(SeriesResource))] [TestCase(typeof(Core.Tv.Series), typeof(SeriesResource))]
[TestCase(typeof(Core.Tv.Episode), typeof(EpisodeResource))] [TestCase(typeof(Episode), typeof(EpisodeResource))]
[TestCase(typeof(RootFolder), typeof(RootFolderResource))] [TestCase(typeof(RootFolder), typeof(RootFolderResource))]
[TestCase(typeof(NamingConfig), typeof(NamingConfigResource))] [TestCase(typeof(NamingConfig), typeof(NamingConfigResource))]
[TestCase(typeof(Indexer), typeof(IndexerResource))] [TestCase(typeof(Indexer), typeof(IndexerResource))]

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Api.REST; using NzbDrone.Api.REST;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Series namespace NzbDrone.Api.Series
@ -22,7 +23,7 @@ public class SeriesResource : RestResource
public DateTime? NextAiring { get; set; } public DateTime? NextAiring { get; set; }
public String Network { get; set; } public String Network { get; set; }
public String AirTime { get; set; } public String AirTime { get; set; }
public List<Core.MediaCover.MediaCover> Images { get; set; } public List<MediaCover> Images { get; set; }
public String RemotePoster { get; set; } public String RemotePoster { get; set; }

View File

@ -17,7 +17,7 @@ public abstract class TinyIoCNancyBootstrapper : NancyBootstrapperWithRequestCon
/// <returns>INancyEngine implementation</returns> /// <returns>INancyEngine implementation</returns>
protected override sealed INancyEngine GetEngineInternal() protected override sealed INancyEngine GetEngineInternal()
{ {
return this.ApplicationContainer.Resolve<INancyEngine>(); return ApplicationContainer.Resolve<INancyEngine>();
} }
/// <summary> /// <summary>
@ -26,7 +26,7 @@ protected override sealed INancyEngine GetEngineInternal()
/// <returns>IModuleKeyGenerator instance</returns> /// <returns>IModuleKeyGenerator instance</returns>
protected override sealed IModuleKeyGenerator GetModuleKeyGenerator() protected override sealed IModuleKeyGenerator GetModuleKeyGenerator()
{ {
return this.ApplicationContainer.Resolve<IModuleKeyGenerator>(); return ApplicationContainer.Resolve<IModuleKeyGenerator>();
} }
/// <summary> /// <summary>
@ -114,7 +114,7 @@ protected override void RegisterInstances(TinyIoCContainer container, IEnumerabl
/// <returns>Request container instance</returns> /// <returns>Request container instance</returns>
protected override sealed TinyIoCContainer CreateRequestContainer() protected override sealed TinyIoCContainer CreateRequestContainer()
{ {
return this.ApplicationContainer.GetChildContainer(); return ApplicationContainer.GetChildContainer();
} }
/// <summary> /// <summary>
@ -123,7 +123,7 @@ protected override sealed TinyIoCContainer CreateRequestContainer()
/// <returns>IDagnostics implementation</returns> /// <returns>IDagnostics implementation</returns>
protected override IDiagnostics GetDiagnostics() protected override IDiagnostics GetDiagnostics()
{ {
return this.ApplicationContainer.Resolve<IDiagnostics>(); return ApplicationContainer.Resolve<IDiagnostics>();
} }
/// <summary> /// <summary>
@ -132,7 +132,7 @@ protected override IDiagnostics GetDiagnostics()
/// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationStartup"/> instances. </returns> /// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationStartup"/> instances. </returns>
protected override IEnumerable<IApplicationStartup> GetApplicationStartupTasks() protected override IEnumerable<IApplicationStartup> GetApplicationStartupTasks()
{ {
return this.ApplicationContainer.ResolveAll<IApplicationStartup>(false); return ApplicationContainer.ResolveAll<IApplicationStartup>(false);
} }
/// <summary> /// <summary>
@ -141,7 +141,7 @@ protected override IEnumerable<IApplicationStartup> GetApplicationStartupTasks()
/// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationRegistrations"/> instances.</returns> /// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationRegistrations"/> instances.</returns>
protected override IEnumerable<IApplicationRegistrations> GetApplicationRegistrationTasks() protected override IEnumerable<IApplicationRegistrations> GetApplicationRegistrationTasks()
{ {
return this.ApplicationContainer.ResolveAll<IApplicationRegistrations>(false); return ApplicationContainer.ResolveAll<IApplicationRegistrations>(false);
} }
/// <summary> /// <summary>

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -53,7 +54,7 @@ public static string GenerateSecurityToken(int length)
var byteSize = (length / 4) * 3; var byteSize = (length / 4) * 3;
var linkBytes = new byte[byteSize]; var linkBytes = new byte[byteSize];
var rngCrypto = new System.Security.Cryptography.RNGCryptoServiceProvider(); var rngCrypto = new RNGCryptoServiceProvider();
rngCrypto.GetBytes(linkBytes); rngCrypto.GetBytes(linkBytes);
var base64String = Convert.ToBase64String(linkBytes); var base64String = Convert.ToBase64String(linkBytes);

View File

@ -42,7 +42,7 @@ protected override void InitializeTarget()
} }
protected override void Write(NLog.LogEventInfo logEvent) protected override void Write(LogEventInfo logEvent)
{ {
var dictionary = new Dictionary<string, object>(); var dictionary = new Dictionary<string, object>();

View File

@ -1,3 +1,4 @@
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace NzbDrone.Common namespace NzbDrone.Common
@ -38,8 +39,8 @@ public static string ToSearchTerm(this string phrase)
public static string RemoveAccent(this string txt) public static string RemoveAccent(this string txt)
{ {
var bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(txt); var bytes = Encoding.GetEncoding("Cyrillic").GetBytes(txt);
return System.Text.Encoding.ASCII.GetString(bytes); return Encoding.ASCII.GetString(bytes);
} }
} }
} }

View File

@ -31,7 +31,7 @@ public class ConfigFileProvider : IConfigFileProvider
public ConfigFileProvider(IAppFolderInfo appFolderInfo, ICacheManger cacheManger) public ConfigFileProvider(IAppFolderInfo appFolderInfo, ICacheManger cacheManger)
{ {
_appFolderInfo = appFolderInfo; _appFolderInfo = appFolderInfo;
_cache = cacheManger.GetCache<string>(this.GetType()); _cache = cacheManger.GetCache<string>(GetType());
_configFile = _appFolderInfo.GetConfigPath(); _configFile = _appFolderInfo.GetConfigPath();
} }

View File

@ -74,18 +74,18 @@ public override string ReadString()
public void CheckForError() public void CheckForError()
{ {
if (this.MoveToContent() == XmlNodeType.Element) if (MoveToContent() == XmlNodeType.Element)
{ {
if (this.Name != "error") if (Name != "error")
return; return;
var message = "Error: "; var message = "Error: ";
if (this.HasAttributes) if (HasAttributes)
{ {
while (this.MoveToNextAttribute()) while (MoveToNextAttribute())
{ {
message += String.Format(" [{0}:{1}]", this.Name, this.Value); message += String.Format(" [{0}:{1}]", Name, Value);
} }
} }

View File

@ -6,6 +6,7 @@
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using NzbDrone.Update.UpdateEngine; using NzbDrone.Update.UpdateEngine;
using IServiceProvider = NzbDrone.Common.IServiceProvider;
namespace NzbDrone.Update.Test namespace NzbDrone.Update.Test
{ {
@ -19,7 +20,7 @@ public void should_start_service_if_app_type_was_serivce()
Subject.Start(AppType.Service, targetFolder); Subject.Start(AppType.Service, targetFolder);
Mocker.GetMock<Common.IServiceProvider>().Verify(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once()); Mocker.GetMock<IServiceProvider>().Verify(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
} }
@ -28,7 +29,7 @@ public void should_start_console_if_app_type_was_serivce_but_start_failed_becaus
{ {
const string targetFolder = "c:\\NzbDrone\\"; const string targetFolder = "c:\\NzbDrone\\";
Mocker.GetMock<Common.IServiceProvider>().Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME)).Throws(new InvalidOperationException()); Mocker.GetMock<IServiceProvider>().Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME)).Throws(new InvalidOperationException());
Subject.Start(AppType.Service, targetFolder); Subject.Start(AppType.Service, targetFolder);