diff --git a/Marr.Data/Converters/CastConverter.cs b/Marr.Data/Converters/CastConverter.cs index 74f3ff8d7..4253357ed 100644 --- a/Marr.Data/Converters/CastConverter.cs +++ b/Marr.Data/Converters/CastConverter.cs @@ -14,10 +14,12 @@ You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ using System; +using System.Globalization; +using Marr.Data.Mapping; namespace Marr.Data.Converters { - public class CastConverter : Marr.Data.Converters.IConverter + public class CastConverter : IConverter where TClr : IConvertible where TDb : IConvertible { @@ -28,16 +30,16 @@ public Type DbType 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; - return val.ToType(typeof(TClr), System.Globalization.CultureInfo.InvariantCulture); + return val.ToType(typeof(TClr), CultureInfo.InvariantCulture); } public object ToDB(object clrValue) { TClr val = (TClr)clrValue; - return val.ToType(typeof(TDb), System.Globalization.CultureInfo.InvariantCulture); + return val.ToType(typeof(TDb), CultureInfo.InvariantCulture); } #endregion diff --git a/Marr.Data/DataMapper.cs b/Marr.Data/DataMapper.cs index 49ebd0125..edc37ea2a 100644 --- a/Marr.Data/DataMapper.cs +++ b/Marr.Data/DataMapper.cs @@ -131,7 +131,7 @@ public IDbDataParameter AddParameter(IDbDataParameter parameter) if (parameter.Value == null) parameter.Value = DBNull.Value; - this.Parameters.Add(parameter); + Parameters.Add(parameter); return parameter; } @@ -395,7 +395,7 @@ public int UpdateDataSet(DataSet ds, string sql) 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) @@ -462,7 +462,7 @@ public int DeleteDataTable(DataTable dt, string sql) public T Find(string sql) { - return this.Find(sql, default(T)); + return Find(sql, default(T)); } /// @@ -526,7 +526,7 @@ public T Find(string sql, T ent) /// Returns a QueryBuilder of T. public QueryBuilder Query() { - var dialect = QGen.QueryFactory.CreateDialect(this); + var dialect = QueryFactory.CreateDialect(this); return new QueryBuilder(this, dialect); } @@ -783,7 +783,7 @@ public int Delete(Expression> filter) public int Delete(string tableName, Expression> filter) { // Remember sql mode - var previousSqlMode = this.SqlMode; + var previousSqlMode = SqlMode; SqlMode = SqlModes.Text; var mappingHelper = new MappingHelper(this); @@ -791,7 +791,7 @@ public int Delete(string tableName, Expression> filter) { tableName = MapRepository.Instance.GetTableName(typeof(T)); } - var dialect = QGen.QueryFactory.CreateDialect(this); + var dialect = QueryFactory.CreateDialect(this); TableCollection tables = new TableCollection(); tables.Add(new Table(typeof(T))); var where = new WhereBuilder(Command, dialect, filter, tables, false, false); diff --git a/Marr.Data/EntityGraph.cs b/Marr.Data/EntityGraph.cs index 5f0b7683e..aee376b61 100644 --- a/Marr.Data/EntityGraph.cs +++ b/Marr.Data/EntityGraph.cs @@ -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 - foreach (Relationship childRelationship in this.Relationships) + foreach (Relationship childRelationship in Relationships) { if (!childRelationship.IsLazyLoaded) { @@ -169,7 +169,7 @@ public void AddEntity(object entityInstance) _entity = entityInstance; // Add newly created entityInstance to list (Many) or set it to field (One) - if (this.IsRoot) + if (IsRoot) { RootList.Add(entityInstance); } @@ -213,7 +213,7 @@ public bool IsNewGroup(DbDataReader reader) bool isNewGroup = false; // Get primary keys from parent entity and any one-to-one child entites - GroupingKeyCollection groupingKeyColumns = this.GroupingKeyColumns; + GroupingKeyCollection groupingKeyColumns = GroupingKeyColumns; // Concatenate column values KeyGroupInfo keyGroupInfo = groupingKeyColumns.CreateGroupingKey(reader); @@ -265,7 +265,7 @@ private bool AnyParentsAreOfType(Type type) private object FindParentReference() { - var parent = this.Parent.Parent; + var parent = Parent.Parent; while (parent != null) { 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. if ((groupingKeyColumns.PrimaryKeys.Count == 0 && _children.Count > 0) || (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 if (IsChild) @@ -378,7 +378,7 @@ private static IEnumerator TraverseGraph(EntityGraph entityGraph) IEnumerator IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } #endregion diff --git a/Marr.Data/GroupingKeyCollection.cs b/Marr.Data/GroupingKeyCollection.cs index 52348bf7f..d38907d9f 100644 --- a/Marr.Data/GroupingKeyCollection.cs +++ b/Marr.Data/GroupingKeyCollection.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Text; using Marr.Data.Mapping; @@ -74,9 +75,9 @@ public IEnumerator GetEnumerator() #region IEnumerable Members - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + IEnumerator IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } #endregion diff --git a/Marr.Data/MapRepository.cs b/Marr.Data/MapRepository.cs index fbb6eca7a..fb3561885 100644 --- a/Marr.Data/MapRepository.cs +++ b/Marr.Data/MapRepository.cs @@ -53,10 +53,10 @@ private MapRepository() ReflectionStrategy = new SimpleReflectionStrategy(); // Register a default type converter for Enums - TypeConverters.Add(typeof(Enum), new Converters.EnumStringConverter()); + TypeConverters.Add(typeof(Enum), new EnumStringConverter()); // Register a default IDbTypeBuilder - _dbTypeBuilder = new Parameters.DbTypeBuilder(); + _dbTypeBuilder = new DbTypeBuilder(); _columnMapStrategies = new Dictionary(); RegisterDefaultMapStrategy(new AttributeMapStrategy()); diff --git a/Marr.Data/Mapping/ColumnInfo.cs b/Marr.Data/Mapping/ColumnInfo.cs index 545f207bb..7e313015d 100644 --- a/Marr.Data/Mapping/ColumnInfo.cs +++ b/Marr.Data/Mapping/ColumnInfo.cs @@ -1,4 +1,6 @@ -namespace Marr.Data.Mapping +using System.Data; + +namespace Marr.Data.Mapping { public class ColumnInfo : IColumnInfo { @@ -7,7 +9,7 @@ public ColumnInfo() IsPrimaryKey = false; IsAutoIncrement = false; ReturnValue = false; - ParamDirection = System.Data.ParameterDirection.Input; + ParamDirection = ParameterDirection.Input; } public string Name { get; set; } @@ -16,7 +18,7 @@ public ColumnInfo() public bool IsPrimaryKey { get; set; } public bool IsAutoIncrement { get; set; } public bool ReturnValue { get; set; } - public System.Data.ParameterDirection ParamDirection { get; set; } + public ParameterDirection ParamDirection { get; set; } public string TryGetAltName() { diff --git a/Marr.Data/Mapping/ColumnMapCollection.cs b/Marr.Data/Mapping/ColumnMapCollection.cs index 6c58dedbb..4c1b57595 100644 --- a/Marr.Data/Mapping/ColumnMapCollection.cs +++ b/Marr.Data/Mapping/ColumnMapCollection.cs @@ -30,12 +30,12 @@ public class ColumnMapCollection : List 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) { - return this.Find(m => m.FieldName == fieldName); + return Find(m => m.FieldName == fieldName); } /// @@ -107,7 +107,7 @@ public ColumnMapCollection PrimaryKeys /// A list of mapped columns that are present in the sql statement as parameters. 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(); if (commandTypeString.Contains("Oracle") || commandTypeString.Contains("OleDb")) @@ -120,7 +120,7 @@ public ColumnMapCollection OrderParameters(DbCommand command) Regex regex = new Regex(regexString); 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) columns.Add(matchingColumn); } @@ -148,7 +148,7 @@ public ColumnMapCollection OrderParameters(DbCommand command) /// 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; } @@ -163,7 +163,7 @@ public ColumnMapCollection PrefixAltNames(string prefix) /// 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; } diff --git a/Marr.Data/Mapping/FluentMappings.cs b/Marr.Data/Mapping/FluentMappings.cs index 526d0365a..8849f1aa1 100644 --- a/Marr.Data/Mapping/FluentMappings.cs +++ b/Marr.Data/Mapping/FluentMappings.cs @@ -55,9 +55,9 @@ public MappingsFluentEntity(bool publicOnly) public class MappingsFluentColumns { private bool _publicOnly; - private FluentMappings.MappingsFluentEntity _fluentEntity; + private MappingsFluentEntity _fluentEntity; - public MappingsFluentColumns(FluentMappings.MappingsFluentEntity fluentEntity, bool publicOnly) + public MappingsFluentColumns(MappingsFluentEntity fluentEntity, bool publicOnly) { _fluentEntity = fluentEntity; _publicOnly = publicOnly; @@ -122,9 +122,9 @@ public ColumnMapBuilder MapProperties() public class MappingsFluentTables { - private FluentMappings.MappingsFluentEntity _fluentEntity; + private MappingsFluentEntity _fluentEntity; - public MappingsFluentTables(FluentMappings.MappingsFluentEntity fluentEntity) + public MappingsFluentTables(MappingsFluentEntity fluentEntity) { _fluentEntity = fluentEntity; } @@ -152,10 +152,10 @@ public TableBuilder MapTable(string tableName) public class MappingsFluentRelationships { - private FluentMappings.MappingsFluentEntity _fluentEntity; + private MappingsFluentEntity _fluentEntity; private bool _publicOnly; - public MappingsFluentRelationships(FluentMappings.MappingsFluentEntity fluentEntity, bool publicOnly) + public MappingsFluentRelationships(MappingsFluentEntity fluentEntity, bool publicOnly) { _fluentEntity = fluentEntity; _publicOnly = publicOnly; diff --git a/Marr.Data/Mapping/Relationship.cs b/Marr.Data/Mapping/Relationship.cs index a28821f44..e7794c633 100644 --- a/Marr.Data/Mapping/Relationship.cs +++ b/Marr.Data/Mapping/Relationship.cs @@ -14,6 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ using System; +using System.Collections; using System.Reflection; using Marr.Data.Reflection; @@ -35,7 +36,7 @@ public Relationship(MemberInfo member, IRelationshipInfo relationshipInfo) // Try to determine the RelationshipType if (relationshipInfo.RelationType == RelationshipTypes.AutoDetect) { - if (typeof(System.Collections.ICollection).IsAssignableFrom(MemberType)) + if (typeof(ICollection).IsAssignableFrom(MemberType)) { relationshipInfo.RelationType = RelationshipTypes.Many; } diff --git a/Marr.Data/Mapping/RelationshipCollection.cs b/Marr.Data/Mapping/RelationshipCollection.cs index 71d112960..8d91c0252 100644 --- a/Marr.Data/Mapping/RelationshipCollection.cs +++ b/Marr.Data/Mapping/RelationshipCollection.cs @@ -28,7 +28,7 @@ public Relationship this[string fieldName] { get { - return this.Find(m => m.Member.Name == fieldName); + return Find(m => m.Member.Name == fieldName); } } } diff --git a/Marr.Data/Mapping/Strategies/ConventionMapStrategy.cs b/Marr.Data/Mapping/Strategies/ConventionMapStrategy.cs index 0015413cd..6230d7fc8 100644 --- a/Marr.Data/Mapping/Strategies/ConventionMapStrategy.cs +++ b/Marr.Data/Mapping/Strategies/ConventionMapStrategy.cs @@ -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)) { @@ -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)) { diff --git a/Marr.Data/Mapping/Strategies/PropertyMapStrategy.cs b/Marr.Data/Mapping/Strategies/PropertyMapStrategy.cs index 71762580e..f9c41afd2 100644 --- a/Marr.Data/Mapping/Strategies/PropertyMapStrategy.cs +++ b/Marr.Data/Mapping/Strategies/PropertyMapStrategy.cs @@ -14,6 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ using System; +using System.Collections; using System.Reflection; namespace Marr.Data.Mapping.Strategies @@ -70,7 +71,7 @@ protected override void CreateRelationship(Type entityType, MemberInfo member, R if (member.MemberType == MemberTypes.Property) { PropertyInfo propertyInfo = member as PropertyInfo; - if (typeof(System.Collections.ICollection).IsAssignableFrom(propertyInfo.PropertyType)) + if (typeof(ICollection).IsAssignableFrom(propertyInfo.PropertyType)) { Relationship relationship = new Relationship(member); relationships.Add(relationship); diff --git a/Marr.Data/Parameters/DbTypeBuilder.cs b/Marr.Data/Parameters/DbTypeBuilder.cs index 839b64c5b..7f5bcee88 100644 --- a/Marr.Data/Parameters/DbTypeBuilder.cs +++ b/Marr.Data/Parameters/DbTypeBuilder.cs @@ -62,7 +62,7 @@ public Enum GetDbType(Type type) return DbType.Object; } - public void SetDbType(System.Data.IDbDataParameter param, Enum dbType) + public void SetDbType(IDbDataParameter param, Enum dbType) { param.DbType = (DbType)dbType; } diff --git a/Marr.Data/Parameters/OleDbTypeBuilder.cs b/Marr.Data/Parameters/OleDbTypeBuilder.cs index a1077531d..e500df501 100644 --- a/Marr.Data/Parameters/OleDbTypeBuilder.cs +++ b/Marr.Data/Parameters/OleDbTypeBuilder.cs @@ -14,6 +14,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ using System; +using System.Data; using System.Data.OleDb; namespace Marr.Data.Parameters @@ -59,7 +60,7 @@ public Enum GetDbType(Type type) return OleDbType.Variant; } - public void SetDbType(System.Data.IDbDataParameter param, Enum dbType) + public void SetDbType(IDbDataParameter param, Enum dbType) { var oleDbParam = (OleDbParameter)param; oleDbParam.OleDbType = (OleDbType)dbType; diff --git a/Marr.Data/Parameters/SqlDbTypeBuilder.cs b/Marr.Data/Parameters/SqlDbTypeBuilder.cs index 813cfcf39..14123df73 100644 --- a/Marr.Data/Parameters/SqlDbTypeBuilder.cs +++ b/Marr.Data/Parameters/SqlDbTypeBuilder.cs @@ -63,7 +63,7 @@ public Enum GetDbType(Type type) return SqlDbType.Variant; } - public void SetDbType(System.Data.IDbDataParameter param, Enum dbType) + public void SetDbType(IDbDataParameter param, Enum dbType) { var sqlDbParam = (SqlParameter)param; sqlDbParam.SqlDbType = (SqlDbType)dbType; diff --git a/Marr.Data/QGen/DeleteQuery.cs b/Marr.Data/QGen/DeleteQuery.cs index 1c0662bb9..7ea5a72fc 100644 --- a/Marr.Data/QGen/DeleteQuery.cs +++ b/Marr.Data/QGen/DeleteQuery.cs @@ -1,4 +1,6 @@ -namespace Marr.Data.QGen +using Marr.Data.QGen.Dialects; + +namespace Marr.Data.QGen { /// /// This class creates a SQL delete query. @@ -7,9 +9,9 @@ public class DeleteQuery : IQuery { protected Table TargetTable { 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; TargetTable = targetTable; diff --git a/Marr.Data/QGen/ExpressionVisitor.cs b/Marr.Data/QGen/ExpressionVisitor.cs index 0ada3ebe4..381688e0e 100644 --- a/Marr.Data/QGen/ExpressionVisitor.cs +++ b/Marr.Data/QGen/ExpressionVisitor.cs @@ -35,7 +35,7 @@ protected virtual Expression Visit(Expression expression) case ExpressionType.Not: case ExpressionType.Quote: case ExpressionType.TypeAs: - return this.VisitUnary((UnaryExpression)expression); + return VisitUnary((UnaryExpression)expression); case ExpressionType.Add: case ExpressionType.AddChecked: case ExpressionType.And: @@ -60,15 +60,15 @@ protected virtual Expression Visit(Expression expression) case ExpressionType.RightShift: case ExpressionType.Subtract: case ExpressionType.SubtractChecked: - return this.VisitBinary((BinaryExpression)expression); + return VisitBinary((BinaryExpression)expression); case ExpressionType.Call: - return this.VisitMethodCall((MethodCallExpression)expression); + return VisitMethodCall((MethodCallExpression)expression); case ExpressionType.Constant: - return this.VisitConstant((ConstantExpression)expression); + return VisitConstant((ConstantExpression)expression); case ExpressionType.MemberAccess: - return this.VisitMemberAccess((MemberExpression)expression); + return VisitMemberAccess((MemberExpression)expression); case ExpressionType.Parameter: - return this.VisitParameter((ParameterExpression)expression); + return VisitParameter((ParameterExpression)expression); } throw new ArgumentOutOfRangeException("expression", expression.NodeType.ToString()); @@ -111,8 +111,8 @@ protected virtual Expression VisitMethodCall(MethodCallExpression expression) /// protected virtual Expression VisitBinary(BinaryExpression expression) { - this.Visit(expression.Left); - this.Visit(expression.Right); + Visit(expression.Left); + Visit(expression.Right); return expression; } @@ -123,7 +123,7 @@ protected virtual Expression VisitBinary(BinaryExpression expression) /// protected virtual Expression VisitUnary(UnaryExpression expression) { - this.Visit(expression.Operand); + Visit(expression.Operand); return expression; } @@ -134,7 +134,7 @@ protected virtual Expression VisitUnary(UnaryExpression expression) /// protected virtual Expression VisitLamda(LambdaExpression lambdaExpression) { - this.Visit(lambdaExpression.Body); + Visit(lambdaExpression.Body); return lambdaExpression; } diff --git a/Marr.Data/QGen/InsertQueryBuilder.cs b/Marr.Data/QGen/InsertQueryBuilder.cs index 9b14d7a0b..85cd0098f 100644 --- a/Marr.Data/QGen/InsertQueryBuilder.cs +++ b/Marr.Data/QGen/InsertQueryBuilder.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Marr.Data.Mapping; using System.Linq.Expressions; +using Marr.Data.QGen.Dialects; namespace Marr.Data.QGen { @@ -15,7 +16,7 @@ public class InsertQueryBuilder : IQueryBuilder private SqlModes _previousSqlMode; private bool _generateQuery = true; private bool _getIdentityValue; - private Dialects.Dialect _dialect; + private Dialect _dialect; private ColumnMapCollection _columnsToInsert; public InsertQueryBuilder() diff --git a/Marr.Data/QGen/QueryBuilder.cs b/Marr.Data/QGen/QueryBuilder.cs index 35b2d109e..cd71c17bd 100644 --- a/Marr.Data/QGen/QueryBuilder.cs +++ b/Marr.Data/QGen/QueryBuilder.cs @@ -6,6 +6,7 @@ using Marr.Data.Mapping; using System.Data.Common; using System.Collections; +using Marr.Data.QGen.Dialects; namespace Marr.Data.QGen { @@ -19,7 +20,7 @@ public class QueryBuilder : ExpressionVisitor, IEnumerable, IQueryBuilder #region - Private Members - private DataMapper _db; - private Dialects.Dialect _dialect; + private Dialect _dialect; private TableCollection _tables; private WhereBuilder _whereBuilder; private SortBuilder _sortBuilder; @@ -71,7 +72,7 @@ public QueryBuilder() // Used only for unit testing with mock frameworks } - public QueryBuilder(DataMapper db, Dialects.Dialect dialect) + public QueryBuilder(DataMapper db, Dialect dialect) { _db = db; _dialect = dialect; @@ -499,7 +500,7 @@ public virtual QueryBuilder Skip(int count) /// /// /// - protected override System.Linq.Expressions.Expression Visit(System.Linq.Expressions.Expression expression) + protected override Expression Visit(Expression expression) { return base.Visit(expression); } @@ -509,9 +510,9 @@ protected override System.Linq.Expressions.Expression Visit(System.Linq.Expressi /// /// /// - protected override System.Linq.Expressions.Expression VisitLamda(System.Linq.Expressions.LambdaExpression lambdaExpression) + protected override Expression VisitLamda(LambdaExpression lambdaExpression) { - _sortBuilder = this.Where(lambdaExpression as Expression>); + _sortBuilder = Where(lambdaExpression as Expression>); return base.VisitLamda(lambdaExpression); } @@ -520,16 +521,16 @@ protected override System.Linq.Expressions.Expression VisitLamda(System.Linq.Exp /// /// /// - protected override System.Linq.Expressions.Expression VisitMethodCall(MethodCallExpression expression) + protected override Expression VisitMethodCall(MethodCallExpression expression) { 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); } 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); } @@ -540,14 +541,14 @@ public virtual QueryBuilder Join(JoinType joinType, Expression { _isJoin = true; MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member; - return this.Join(joinType, rightMember, filterExpression); + return Join(joinType, rightMember, filterExpression); } public virtual QueryBuilder Join(JoinType joinType, Expression> rightEntity, Expression> filterExpression) { _isJoin = true; MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member; - return this.Join(joinType, rightMember, filterExpression); + return Join(joinType, rightMember, filterExpression); } public virtual QueryBuilder Join(JoinType joinType, MemberInfo rightMember, Expression> filterExpression) @@ -598,7 +599,7 @@ public virtual bool Any() IEnumerator IEnumerable.GetEnumerator() { - var list = this.ToList(); + var list = ToList(); return list.GetEnumerator(); } @@ -608,7 +609,7 @@ IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator() { - var list = this.ToList(); + var list = ToList(); return list.GetEnumerator(); } diff --git a/Marr.Data/QGen/QueryFactory.cs b/Marr.Data/QGen/QueryFactory.cs index 1e020e7be..5e1d90b9a 100644 --- a/Marr.Data/QGen/QueryFactory.cs +++ b/Marr.Data/QGen/QueryFactory.cs @@ -1,4 +1,5 @@ using System; +using Marr.Data.Mapping; using Marr.Data.QGen.Dialects; namespace Marr.Data.QGen @@ -16,19 +17,19 @@ internal class QueryFactory private const string DB_FireBirdClient = "FirebirdSql.Data.FirebirdClient.FirebirdClientFactory"; 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); 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); 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); } @@ -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(); switch (providerString) diff --git a/Marr.Data/QGen/SortBuilder.cs b/Marr.Data/QGen/SortBuilder.cs index 75e360cda..32c85eccd 100644 --- a/Marr.Data/QGen/SortBuilder.cs +++ b/Marr.Data/QGen/SortBuilder.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Text; using System.Linq.Expressions; @@ -243,7 +244,7 @@ public static implicit operator List(SortBuilder builder) public virtual IEnumerator GetEnumerator() { - var list = this.ToList(); + var list = ToList(); return list.GetEnumerator(); } @@ -251,7 +252,7 @@ public virtual IEnumerator GetEnumerator() #region IEnumerable Members - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); } diff --git a/Marr.Data/QGen/TableCollection.cs b/Marr.Data/QGen/TableCollection.cs index 41c8a8d07..5a69fe978 100644 --- a/Marr.Data/QGen/TableCollection.cs +++ b/Marr.Data/QGen/TableCollection.cs @@ -41,7 +41,7 @@ public void ReplaceBaseTable(View view) /// 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] diff --git a/Marr.Data/QGen/UpdateQueryBuilder.cs b/Marr.Data/QGen/UpdateQueryBuilder.cs index ca9c3aaa7..6e12d76ae 100644 --- a/Marr.Data/QGen/UpdateQueryBuilder.cs +++ b/Marr.Data/QGen/UpdateQueryBuilder.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Marr.Data.Mapping; using System.Linq.Expressions; +using Marr.Data.QGen.Dialects; namespace Marr.Data.QGen { @@ -16,7 +17,7 @@ public class UpdateQueryBuilder private bool _generateQuery = true; private TableCollection _tables; private Expression> _filterExpression; - private Dialects.Dialect _dialect; + private Dialect _dialect; private ColumnMapCollection _columnsToUpdate; public UpdateQueryBuilder() diff --git a/Marr.Data/QGen/View.cs b/Marr.Data/QGen/View.cs index 1d2386677..f750c2e06 100644 --- a/Marr.Data/QGen/View.cs +++ b/Marr.Data/QGen/View.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System.Collections; +using System.Collections.Generic; using System.Linq; using Marr.Data.Mapping; @@ -11,7 +12,7 @@ public class View : Table, IEnumerable { private string _viewName; private Table[] _tables; - private Mapping.ColumnMapCollection _columns; + private ColumnMapCollection _columns; public View(string viewName, Table[] tables) : base(tables[0].EntityType, JoinType.None) @@ -58,7 +59,7 @@ public override string Alias /// /// Gets all the columns from all the tables included in the view. /// - public override Mapping.ColumnMapCollection Columns + public override ColumnMapCollection Columns { get { @@ -81,9 +82,9 @@ public IEnumerator
GetEnumerator() } } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + IEnumerator IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } } } diff --git a/Marr.Data/QGen/WhereBuilder.cs b/Marr.Data/QGen/WhereBuilder.cs index ad726b578..a227891d1 100644 --- a/Marr.Data/QGen/WhereBuilder.cs +++ b/Marr.Data/QGen/WhereBuilder.cs @@ -78,7 +78,7 @@ protected override Expression VisitBinary(BinaryExpression 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) { case "Contains": @@ -270,7 +270,7 @@ private void Write_EndsWith(MethodCallExpression body) internal void Append(WhereBuilder where, WhereAppendType appendType) { _constantWhereClause = string.Format("{0} {1} {2}", - this.ToString(), + ToString(), appendType.ToString(), where.ToString().Replace("WHERE ", string.Empty)); } diff --git a/Marr.Data/UnitOfWork.cs b/Marr.Data/UnitOfWork.cs index cdd829d69..16327427c 100644 --- a/Marr.Data/UnitOfWork.cs +++ b/Marr.Data/UnitOfWork.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.Serialization; namespace Marr.Data { @@ -118,8 +119,8 @@ public NestedSharedContextRollBackException() { } public NestedSharedContextRollBackException(string message) : base(message) { } public NestedSharedContextRollBackException(string message, Exception inner) : base(message, inner) { } protected NestedSharedContextRollBackException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) + SerializationInfo info, + StreamingContext context) : base(info, context) { } } } diff --git a/NzbDrone.Api.Test/MappingTests/ResourceMappingFixture.cs b/NzbDrone.Api.Test/MappingTests/ResourceMappingFixture.cs index 2d5c19f0f..2aaf97b79 100644 --- a/NzbDrone.Api.Test/MappingTests/ResourceMappingFixture.cs +++ b/NzbDrone.Api.Test/MappingTests/ResourceMappingFixture.cs @@ -21,6 +21,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.RootFolders; +using NzbDrone.Core.Tv; using NzbDrone.Core.Update; using NzbDrone.Test.Common; using System.Linq; @@ -31,7 +32,7 @@ namespace NzbDrone.Api.Test.MappingTests public class ResourceMappingFixture : TestBase { [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(NamingConfig), typeof(NamingConfigResource))] [TestCase(typeof(Indexer), typeof(IndexerResource))] diff --git a/NzbDrone.Api/Series/SeriesResource.cs b/NzbDrone.Api/Series/SeriesResource.cs index 5b0ef2641..34f7dcead 100644 --- a/NzbDrone.Api/Series/SeriesResource.cs +++ b/NzbDrone.Api/Series/SeriesResource.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using NzbDrone.Api.REST; +using NzbDrone.Core.MediaCover; using NzbDrone.Core.Tv; namespace NzbDrone.Api.Series @@ -22,7 +23,7 @@ public class SeriesResource : RestResource public DateTime? NextAiring { get; set; } public String Network { get; set; } public String AirTime { get; set; } - public List Images { get; set; } + public List Images { get; set; } public String RemotePoster { get; set; } diff --git a/NzbDrone.Api/TinyIoCNancyBootstrapper.cs b/NzbDrone.Api/TinyIoCNancyBootstrapper.cs index 8ed1c5795..03fef1b77 100644 --- a/NzbDrone.Api/TinyIoCNancyBootstrapper.cs +++ b/NzbDrone.Api/TinyIoCNancyBootstrapper.cs @@ -17,7 +17,7 @@ public abstract class TinyIoCNancyBootstrapper : NancyBootstrapperWithRequestCon /// INancyEngine implementation protected override sealed INancyEngine GetEngineInternal() { - return this.ApplicationContainer.Resolve(); + return ApplicationContainer.Resolve(); } /// @@ -26,7 +26,7 @@ protected override sealed INancyEngine GetEngineInternal() /// IModuleKeyGenerator instance protected override sealed IModuleKeyGenerator GetModuleKeyGenerator() { - return this.ApplicationContainer.Resolve(); + return ApplicationContainer.Resolve(); } /// @@ -114,7 +114,7 @@ protected override void RegisterInstances(TinyIoCContainer container, IEnumerabl /// Request container instance protected override sealed TinyIoCContainer CreateRequestContainer() { - return this.ApplicationContainer.GetChildContainer(); + return ApplicationContainer.GetChildContainer(); } /// @@ -123,7 +123,7 @@ protected override sealed TinyIoCContainer CreateRequestContainer() /// IDagnostics implementation protected override IDiagnostics GetDiagnostics() { - return this.ApplicationContainer.Resolve(); + return ApplicationContainer.Resolve(); } /// @@ -132,7 +132,7 @@ protected override IDiagnostics GetDiagnostics() /// An instance containing instances. protected override IEnumerable GetApplicationStartupTasks() { - return this.ApplicationContainer.ResolveAll(false); + return ApplicationContainer.ResolveAll(false); } /// @@ -141,7 +141,7 @@ protected override IEnumerable GetApplicationStartupTasks() /// An instance containing instances. protected override IEnumerable GetApplicationRegistrationTasks() { - return this.ApplicationContainer.ResolveAll(false); + return ApplicationContainer.ResolveAll(false); } /// diff --git a/NzbDrone.Common/HashUtil.cs b/NzbDrone.Common/HashUtil.cs index 53571eae0..0a127ee63 100644 --- a/NzbDrone.Common/HashUtil.cs +++ b/NzbDrone.Common/HashUtil.cs @@ -1,4 +1,5 @@ using System; +using System.Security.Cryptography; using System.Text; using System.Threading; @@ -53,7 +54,7 @@ public static string GenerateSecurityToken(int length) var byteSize = (length / 4) * 3; var linkBytes = new byte[byteSize]; - var rngCrypto = new System.Security.Cryptography.RNGCryptoServiceProvider(); + var rngCrypto = new RNGCryptoServiceProvider(); rngCrypto.GetBytes(linkBytes); var base64String = Convert.ToBase64String(linkBytes); diff --git a/NzbDrone.Common/Instrumentation/LogglyTarget.cs b/NzbDrone.Common/Instrumentation/LogglyTarget.cs index ccb5e706f..33d953390 100644 --- a/NzbDrone.Common/Instrumentation/LogglyTarget.cs +++ b/NzbDrone.Common/Instrumentation/LogglyTarget.cs @@ -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(); diff --git a/NzbDrone.Common/StringExtensions.cs b/NzbDrone.Common/StringExtensions.cs index c4fe462fb..bddd4cd77 100644 --- a/NzbDrone.Common/StringExtensions.cs +++ b/NzbDrone.Common/StringExtensions.cs @@ -1,3 +1,4 @@ +using System.Text; using System.Text.RegularExpressions; namespace NzbDrone.Common @@ -38,8 +39,8 @@ public static string ToSearchTerm(this string phrase) public static string RemoveAccent(this string txt) { - var bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(txt); - return System.Text.Encoding.ASCII.GetString(bytes); + var bytes = Encoding.GetEncoding("Cyrillic").GetBytes(txt); + return Encoding.ASCII.GetString(bytes); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 71e4e8aba..89c427fb2 100644 --- a/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -31,7 +31,7 @@ public class ConfigFileProvider : IConfigFileProvider public ConfigFileProvider(IAppFolderInfo appFolderInfo, ICacheManger cacheManger) { _appFolderInfo = appFolderInfo; - _cache = cacheManger.GetCache(this.GetType()); + _cache = cacheManger.GetCache(GetType()); _configFile = _appFolderInfo.GetConfigPath(); } diff --git a/NzbDrone.Core/Indexers/SyndicationFeedXmlReader.cs b/NzbDrone.Core/Indexers/SyndicationFeedXmlReader.cs index a72c5242d..f6024a9f8 100644 --- a/NzbDrone.Core/Indexers/SyndicationFeedXmlReader.cs +++ b/NzbDrone.Core/Indexers/SyndicationFeedXmlReader.cs @@ -74,18 +74,18 @@ public override string ReadString() public void CheckForError() { - if (this.MoveToContent() == XmlNodeType.Element) + if (MoveToContent() == XmlNodeType.Element) { - if (this.Name != "error") + if (Name != "error") return; 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); } } diff --git a/NzbDrone.Update.Test/StartNzbDroneService.cs b/NzbDrone.Update.Test/StartNzbDroneService.cs index 26388b22b..c4fc01ca7 100644 --- a/NzbDrone.Update.Test/StartNzbDroneService.cs +++ b/NzbDrone.Update.Test/StartNzbDroneService.cs @@ -6,6 +6,7 @@ using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Test.Common; using NzbDrone.Update.UpdateEngine; +using IServiceProvider = NzbDrone.Common.IServiceProvider; namespace NzbDrone.Update.Test { @@ -19,7 +20,7 @@ public void should_start_service_if_app_type_was_serivce() Subject.Start(AppType.Service, targetFolder); - Mocker.GetMock().Verify(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once()); + Mocker.GetMock().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\\"; - Mocker.GetMock().Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME)).Throws(new InvalidOperationException()); + Mocker.GetMock().Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME)).Throws(new InvalidOperationException()); Subject.Start(AppType.Service, targetFolder);