From: <fab...@us...> - 2010-07-28 17:48:10
|
Revision: 5066 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5066&view=rev Author: fabiomaulo Date: 2010-07-28 17:48:04 +0000 (Wed, 28 Jul 2010) Log Message: ----------- Minor (renaming) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2010-07-28 16:51:31 UTC (rev 5065) +++ trunk/nhibernate/src/NHibernate/Linq/Functions/BaseHqlGeneratorForType.cs 2010-07-28 17:48:04 UTC (rev 5066) @@ -16,7 +16,7 @@ { foreach (var method in generator.SupportedMethods) { - functionRegistry.RegisterMethodGenerator(method, generator); + functionRegistry.RegisterGenerator(method, generator); } } @@ -24,7 +24,7 @@ { foreach (var property in generator.SupportedProperties) { - functionRegistry.RegisterPropertyGenerator(property, generator); + functionRegistry.RegisterGenerator(property, generator); } } } Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 16:51:31 UTC (rev 5065) +++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 17:48:04 UTC (rev 5066) @@ -13,9 +13,9 @@ { public static readonly FunctionRegistry Instance = new FunctionRegistry(); - private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> _registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>(); - private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> _registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>(); - private readonly List<IHqlGeneratorForType> _typeGenerators = new List<IHqlGeneratorForType>(); + private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>(); + private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>(); + private readonly List<IHqlGeneratorForType> typeGenerators = new List<IHqlGeneratorForType>(); private FunctionRegistry() { @@ -26,7 +26,7 @@ Register(new ICollectionGenerator()); } - public IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method) + public IHqlGeneratorForMethod GetGenerator(MethodInfo method) { IHqlGeneratorForMethod methodGenerator; @@ -60,7 +60,7 @@ { methodGenerator = null; - foreach (var typeGenerator in _typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method))) + foreach (var typeGenerator in typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method))) { methodGenerator = typeGenerator.GetMethodGenerator(method); return true; @@ -85,18 +85,18 @@ private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) { - if (_registeredMethods.TryGetValue(method, out methodGenerator)) + if (registeredMethods.TryGetValue(method, out methodGenerator)) { return true; } return false; } - public IHqlGeneratorForProperty GetPropertyGenerator(MemberInfo member) + public IHqlGeneratorForProperty GetGenerator(MemberInfo member) { IHqlGeneratorForProperty propertyGenerator; - if (_registeredProperties.TryGetValue(member, out propertyGenerator)) + if (registeredProperties.TryGetValue(member, out propertyGenerator)) { return propertyGenerator; } @@ -105,19 +105,19 @@ return null; } - public void RegisterMethodGenerator(MethodInfo method, IHqlGeneratorForMethod generator) + public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator) { - _registeredMethods.Add(method, generator); + registeredMethods.Add(method, generator); } - public void RegisterPropertyGenerator(MemberInfo property, IHqlGeneratorForProperty generator) + public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator) { - _registeredProperties.Add(property, generator); + registeredProperties.Add(property, generator); } private void Register(IHqlGeneratorForType typeMethodGenerator) { - _typeGenerators.Add(typeMethodGenerator); + typeGenerators.Add(typeMethodGenerator); typeMethodGenerator.Register(this); } } Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 16:51:31 UTC (rev 5065) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 17:48:04 UTC (rev 5066) @@ -351,7 +351,7 @@ } // Look for "special" properties (DateTime.Month etc) - var generator = FunctionRegistry.GetPropertyGenerator(expression.Member); + var generator = FunctionRegistry.GetGenerator(expression.Member); if (generator != null) { @@ -394,7 +394,7 @@ protected HqlTreeNode VisitMethodCallExpression(MethodCallExpression expression) { - var generator = FunctionRegistry.GetMethodGenerator(expression.Method); + var generator = FunctionRegistry.GetGenerator(expression.Method); return generator.BuildHql(expression.Method, expression.Object, expression.Arguments, _hqlTreeBuilder, this); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-28 19:38:19
|
Revision: 5068 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5068&view=rev Author: fabiomaulo Date: 2010-07-28 19:38:13 +0000 (Wed, 28 Jul 2010) Log Message: ----------- Refactoring Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:23:54 UTC (rev 5067) +++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:38:13 UTC (rev 5068) @@ -10,7 +10,7 @@ { public class FunctionRegistry : ILinqToHqlGeneratorsRegistry { - public static readonly FunctionRegistry Instance = new FunctionRegistry(); + public static readonly ILinqToHqlGeneratorsRegistry Instance = new FunctionRegistry(); private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>(); private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>(); Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 19:23:54 UTC (rev 5067) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/HqlGeneratorExpressionTreeVisitor.cs 2010-07-28 19:38:13 UTC (rev 5068) @@ -12,7 +12,7 @@ { private readonly HqlTreeBuilder _hqlTreeBuilder; private readonly VisitorParameters _parameters; - static private readonly FunctionRegistry FunctionRegistry = FunctionRegistry.Instance; + private readonly ILinqToHqlGeneratorsRegistry functionRegistry; public static HqlTreeNode Visit(Expression expression, VisitorParameters parameters) { @@ -23,7 +23,8 @@ public HqlGeneratorExpressionTreeVisitor(VisitorParameters parameters) { - _parameters = parameters; + functionRegistry = FunctionRegistry.Instance; + _parameters = parameters; _hqlTreeBuilder = new HqlTreeBuilder(); } @@ -352,9 +353,8 @@ // Look for "special" properties (DateTime.Month etc) IHqlGeneratorForProperty generator; - generator = FunctionRegistry.GetGenerator(expression.Member); - if (generator != null) + if (functionRegistry.TryGetGenerator(expression.Member, out generator)) { return generator.BuildHql(expression.Member, expression.Expression, _hqlTreeBuilder, this); } @@ -398,7 +398,7 @@ IHqlGeneratorForMethod generator; var method = expression.Method; - if (!FunctionRegistry.TryGetGenerator(method, out generator)) + if (!functionRegistry.TryGetGenerator(method, out generator)) { throw new NotSupportedException(method.ToString()); } Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:23:54 UTC (rev 5067) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:38:13 UTC (rev 5068) @@ -10,7 +10,7 @@ { public class SelectClauseVisitor : ExpressionTreeVisitor { - static private readonly FunctionRegistry FunctionRegistry = FunctionRegistry.Instance; + private readonly ILinqToHqlGeneratorsRegistry functionRegistry; private HashSet<Expression> _hqlNodes; private readonly ParameterExpression _inputParameter; @@ -20,7 +20,8 @@ public SelectClauseVisitor(System.Type inputType, VisitorParameters parameters) { - _inputParameter = Expression.Parameter(inputType, "input"); + functionRegistry = FunctionRegistry.Instance; + _inputParameter = Expression.Parameter(inputType, "input"); _parameters = parameters; } @@ -82,7 +83,7 @@ { // Depends if it's in the function registry IHqlGeneratorForMethod methodGenerator; - if (!FunctionRegistry.TryGetGenerator(((MethodCallExpression) expression).Method, out methodGenerator)) + if (!functionRegistry.TryGetGenerator(((MethodCallExpression) expression).Method, out methodGenerator)) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-28 19:45:31
|
Revision: 5069 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5069&view=rev Author: fabiomaulo Date: 2010-07-28 19:45:24 +0000 (Wed, 28 Jul 2010) Log Message: ----------- - Fixed the build (sorry) - Removed unused method Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs Modified: trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:38:13 UTC (rev 5068) +++ trunk/nhibernate/src/NHibernate/Linq/Functions/FunctionRegistry.cs 2010-07-28 19:45:24 UTC (rev 5069) @@ -12,68 +12,55 @@ { public static readonly ILinqToHqlGeneratorsRegistry Instance = new FunctionRegistry(); - private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>(); - private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>(); - private readonly List<IHqlGeneratorForType> typeGenerators = new List<IHqlGeneratorForType>(); + private readonly Dictionary<MethodInfo, IHqlGeneratorForMethod> registeredMethods = new Dictionary<MethodInfo, IHqlGeneratorForMethod>(); + private readonly Dictionary<MemberInfo, IHqlGeneratorForProperty> registeredProperties = new Dictionary<MemberInfo, IHqlGeneratorForProperty>(); + private readonly List<IHqlGeneratorForType> typeGenerators = new List<IHqlGeneratorForType>(); - private FunctionRegistry() - { - // TODO - could use reflection here - Register(new QueryableGenerator()); - Register(new StringGenerator()); - Register(new DateTimeGenerator()); - Register(new ICollectionGenerator()); - } + private FunctionRegistry() + { + // TODO - could use reflection here + Register(new QueryableGenerator()); + Register(new StringGenerator()); + Register(new DateTimeGenerator()); + Register(new ICollectionGenerator()); + } - private bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) - { - methodGenerator = null; + private bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) + { + methodGenerator = null; - foreach (var typeGenerator in typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method))) - { - methodGenerator = typeGenerator.GetMethodGenerator(method); - return true; - } - return false; - } + foreach (var typeGenerator in typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method))) + { + methodGenerator = typeGenerator.GetMethodGenerator(method); + return true; + } + return false; + } - private bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) - { - methodGenerator = null; + private bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) + { + methodGenerator = null; - var attr = method.GetCustomAttributes(typeof(LinqExtensionMethodAttribute), false); + var attr = method.GetCustomAttributes(typeof(LinqExtensionMethodAttribute), false); - if (attr.Length == 1) - { - // It is - methodGenerator = new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute)attr[0], method); - return true; - } - return false; - } + if (attr.Length == 1) + { + // It is + methodGenerator = new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute)attr[0], method); + return true; + } + return false; + } - private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) - { - if (registeredMethods.TryGetValue(method, out methodGenerator)) - { - return true; - } - return false; - } + private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) + { + if (registeredMethods.TryGetValue(method, out methodGenerator)) + { + return true; + } + return false; + } - public IHqlGeneratorForProperty GetGenerator(MemberInfo member) - { - IHqlGeneratorForProperty propertyGenerator; - - if (registeredProperties.TryGetValue(member, out propertyGenerator)) - { - return propertyGenerator; - } - - // TODO - different usage pattern to method generator - return null; - } - public bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator) { if (method.IsGenericMethod) @@ -98,21 +85,21 @@ } public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator) - { - registeredMethods.Add(method, generator); - } + { + registeredMethods.Add(method, generator); + } - public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator) - { - registeredProperties.Add(property, generator); - } + public void RegisterGenerator(MemberInfo property, IHqlGeneratorForProperty generator) + { + registeredProperties.Add(property, generator); + } - private void Register(IHqlGeneratorForType typeMethodGenerator) - { - typeGenerators.Add(typeMethodGenerator); - typeMethodGenerator.Register(this); - } - } + private void Register(IHqlGeneratorForType typeMethodGenerator) + { + typeGenerators.Add(typeMethodGenerator); + typeMethodGenerator.Register(this); + } + } public class HqlGeneratorForExtensionMethod : BaseHqlGeneratorForMethod { Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:38:13 UTC (rev 5068) +++ trunk/nhibernate/src/NHibernate/Linq/Visitors/SelectClauseVisitor.cs 2010-07-28 19:45:24 UTC (rev 5069) @@ -71,7 +71,7 @@ return base.VisitExpression(expression); } - private static bool CanBeEvaluatedInHqlSelectStatement(Expression expression) + private bool CanBeEvaluatedInHqlSelectStatement(Expression expression) { if ((expression.NodeType == ExpressionType.MemberInit) || (expression.NodeType == ExpressionType.New) || (expression.NodeType == ExpressionType.Constant)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2011-04-08 05:49:01
|
Revision: 5640 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5640&view=rev Author: fabiomaulo Date: 2011-04-08 05:48:54 +0000 (Fri, 08 Apr 2011) Log Message: ----------- Minor relax Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Linq/DefaultQueryProvider.cs trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs Modified: trunk/nhibernate/src/NHibernate/Linq/DefaultQueryProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/DefaultQueryProvider.cs 2011-04-08 05:38:39 UTC (rev 5639) +++ trunk/nhibernate/src/NHibernate/Linq/DefaultQueryProvider.cs 2011-04-08 05:48:54 UTC (rev 5640) @@ -9,8 +9,14 @@ namespace NHibernate.Linq { - public class DefaultQueryProvider : IQueryProvider + public interface INhQueryProvider : IQueryProvider { + object ExecuteFuture(Expression expression); + void SetResultTransformerAndAdditionalCriteria(IQuery query, NhLinqExpression nhExpression, IDictionary<string, Tuple<object, IType>> parameters); + } + + public class DefaultQueryProvider : INhQueryProvider + { public DefaultQueryProvider(ISessionImplementor session) { Session = session; @@ -34,14 +40,14 @@ return (TResult) Execute(expression); } - public IQueryable CreateQuery(Expression expression) + public virtual IQueryable CreateQuery(Expression expression) { MethodInfo m = ReflectionHelper.GetMethodDefinition((DefaultQueryProvider p) => p.CreateQuery<object>(null)).MakeGenericMethod(expression.Type.GetGenericArguments()[0]); return (IQueryable) m.Invoke(this, new[] {expression}); } - public IQueryable<T> CreateQuery<T>(Expression expression) + public virtual IQueryable<T> CreateQuery<T>(Expression expression) { return new NhQueryable<T>(this, expression); } Modified: trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs 2011-04-08 05:38:39 UTC (rev 5639) +++ trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs 2011-04-08 05:48:54 UTC (rev 5640) @@ -53,7 +53,7 @@ throw new NotSupportedException("You can also use the AsFuture() method on NhQueryable"); - var future = ((DefaultQueryProvider)nhQueryable.Provider).ExecuteFuture(nhQueryable.Expression); + var future = ((INhQueryProvider)nhQueryable.Provider).ExecuteFuture(nhQueryable.Expression); return (IEnumerable<T>)future; } @@ -63,7 +63,7 @@ if (nhQueryable == null) throw new NotSupportedException("You can also use the AsFuture() method on NhQueryable"); - var future = ((DefaultQueryProvider)nhQueryable.Provider).ExecuteFuture(nhQueryable.Expression); + var future = ((INhQueryProvider)nhQueryable.Provider).ExecuteFuture(nhQueryable.Expression); if(future is DelayedEnumerator<T>) { return new FutureValue<T>(() => ((IEnumerable<T>) future)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |