Permalink
Browse files

Small code cleanups

  • Loading branch information...
1 parent 2d93b53 commit 88a4f98deb4e4c908d193d12660d741b34d4c8ea @hazzik hazzik committed Sep 17, 2012
@@ -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);
}
@@ -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);
}
@@ -77,32 +77,30 @@ private class ResultOperatorExpressionRewriter : ExpressionTreeVisitor
/// </summary>
public IEnumerable<ResultOperatorBase> ResultOperators
{
- get { return this.resultOperators; }
+ get { return resultOperators; }
}
/// <summary>
/// Gets the <see cref="IStreamedDataInfo" /> representing the type of data that the operator works upon.
/// </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)
{
@@ -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);
+ }
}
@@ -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);
@@ -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;

0 comments on commit 88a4f98

Please sign in to comment.