Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Small code cleanups

  • Loading branch information...
commit 88a4f98deb4e4c908d193d12660d741b34d4c8ea 1 parent 2d93b53
@hazzik hazzik authored
View
4 src/NHibernate/Linq/ExpressionTransformers/RemoveCharToIntConversion.cs
@@ -46,12 +46,12 @@ public Expression Transform(BinaryExpression expression)
return expression;
}
- private bool IsConvertExpression(Expression expression)
+ private static bool IsConvertExpression(Expression expression)
{
return (expression.NodeType == ExpressionType.Convert);
}
- private bool IsConstantExpression(Expression expression)
+ private static bool IsConstantExpression(Expression expression)
{
return (expression.NodeType == ExpressionType.Constant);
}
View
2  src/NHibernate/Linq/IntermediateHqlTree.cs
@@ -121,7 +121,7 @@ private void ExecuteAddOrderBy(HqlTreeNode orderBy)
if (orderBy == null)
return;
- if (!_root.NodesPreOrder.Any(x => x == orderBy))
+ if (_root.NodesPreOrder.All(x => x != orderBy))
_root.AddChild(orderBy);
}
View
16 src/NHibernate/Linq/ReWriters/ResultOperatorRewriter.cs
@@ -77,7 +77,7 @@ private class ResultOperatorExpressionRewriter : ExpressionTreeVisitor
/// </summary>
public IEnumerable<ResultOperatorBase> ResultOperators
{
- get { return this.resultOperators; }
+ get { return resultOperators; }
}
/// <summary>
@@ -85,24 +85,22 @@ public IEnumerable<ResultOperatorBase> ResultOperators
/// </summary>
public IStreamedDataInfo EvaluationType
{
- get { return this.evaluationType; }
+ get { return evaluationType; }
}
public Expression Rewrite(Expression expression)
{
- Expression rewrittenExpression = this.VisitExpression(expression);
-
- return rewrittenExpression;
+ return VisitExpression(expression);
}
protected override Expression VisitSubQueryExpression(SubQueryExpression expression)
{
- this.resultOperators.AddRange(
+ resultOperators.AddRange(
expression.QueryModel.ResultOperators
- .Where(r => rewrittenTypes.Any(t => t.IsAssignableFrom(r.GetType()))));
+ .Where(r => rewrittenTypes.Any(t => t.IsInstanceOfType(r))));
- this.resultOperators.ForEach(f => expression.QueryModel.ResultOperators.Remove(f));
- this.evaluationType = expression.QueryModel.SelectClause.GetOutputDataInfo();
+ resultOperators.ForEach(f => expression.QueryModel.ResultOperators.Remove(f));
+ evaluationType = expression.QueryModel.SelectClause.GetOutputDataInfo();
if (expression.QueryModel.ResultOperators.Count == 0)
{
View
8 src/NHibernate/Linq/Visitors/ResultOperatorProcessors/IResultOperatorProcessor.cs
@@ -1,7 +1,7 @@
namespace NHibernate.Linq.Visitors.ResultOperatorProcessors
{
- public interface IResultOperatorProcessor<T>
- {
- void Process(T resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree);
- }
+ public interface IResultOperatorProcessor<T>
+ {
+ void Process(T resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree);
+ }
}
View
8 src/NHibernate/Linq/Visitors/SelectClauseNominator.cs
@@ -35,12 +35,8 @@ public override Expression VisitExpression(Expression expression)
{
try
{
- bool projectConstantsInHql = _stateStack.Peek();
-
- if (!projectConstantsInHql && expression != null && IsRegisteredFunction(expression))
- {
- projectConstantsInHql = true;
- }
+ var projectConstantsInHql = _stateStack.Peek() ||
+ expression != null && IsRegisteredFunction(expression);
_stateStack.Push(projectConstantsInHql);
View
11 src/NHibernate/Linq/Visitors/VisitorUtil.cs
@@ -1,19 +1,14 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Linq.Expressions;
using System.Collections;
-using NHibernate.Metadata;
-using NHibernate.Type;
using System.Reflection;
-using System.Collections.ObjectModel;
namespace NHibernate.Linq.Visitors
{
- public class VisitorUtil
+ public static class VisitorUtil
{
- public static bool IsDynamicComponentDictionaryGetter(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, ISessionFactory sessionFactory, out string memberName)
+ public static bool IsDynamicComponentDictionaryGetter(MethodInfo method, Expression targetObject, IEnumerable<Expression> arguments, ISessionFactory sessionFactory, out string memberName)
{
memberName = null;
Please sign in to comment.
Something went wrong with that request. Please try again.