static NhRelinqQueryParser() { var preTransformerRegistry = new ExpressionTransformerRegistry(); // NH-3247: must remove .Net compiler char to int conversion before // parameterization occurs. preTransformerRegistry.Register(new RemoveCharToIntConversion()); PreProcessor = new TransformingExpressionTreeProcessor(preTransformerRegistry); var transformerRegistry = ExpressionTransformerRegistry.CreateDefault(); transformerRegistry.Register(new RemoveRedundantCast()); transformerRegistry.Register(new SimplifyCompareTransformer()); // If needing a compound processor for adding other processing, do not use // ExpressionTreeParser.CreateDefaultProcessor(transformerRegistry), it would // cause NH-3961 again by including a PartialEvaluatingExpressionTreeProcessor. // Directly instantiate a CompoundExpressionTreeProcessor instead. var processor = new TransformingExpressionTreeProcessor(transformerRegistry); var nodeTypeProvider = new NHibernateNodeTypeProvider(); var expressionTreeParser = new ExpressionTreeParser(nodeTypeProvider, processor); QueryParser = new QueryParser(expressionTreeParser); }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionTreeParser"/> class with a custom <see cref="INodeTypeProvider"/> and /// <see cref="IExpressionTreeProcessor"/> implementation. /// </summary> /// <param name="nodeTypeProvider">The <see cref="INodeTypeProvider"/> to use when parsing <see cref="Expression"/> trees. Use /// <see cref="CreateDefaultNodeTypeProvider"/> to create an instance of <see cref="CompoundNodeTypeProvider"/> that already includes all /// default node types. (The <see cref="CompoundNodeTypeProvider"/> can be customized as needed by adding or removing /// <see cref="CompoundNodeTypeProvider.InnerProviders"/>).</param> /// <param name="processor">The <see cref="IExpressionTreeProcessor"/> to apply to <see cref="Expression"/> trees before parsing their nodes. Use /// <see cref="CreateDefaultProcessor"/> to create an instance of <see cref="CompoundExpressionTreeProcessor"/> that already includes /// the default steps. (The <see cref="CompoundExpressionTreeProcessor"/> can be customized as needed by adding or removing /// <see cref="CompoundExpressionTreeProcessor.InnerProcessors"/>).</param> public ExpressionTreeParser(INodeTypeProvider nodeTypeProvider, IExpressionTreeProcessor processor) { ArgumentUtility.CheckNotNull("nodeTypeProvider", nodeTypeProvider); ArgumentUtility.CheckNotNull("processor", processor); _nodeTypeProvider = nodeTypeProvider; _processor = processor; _methodCallExpressionParser = new MethodCallExpressionParser(_nodeTypeProvider); }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionTreeParser"/> class with a custom <see cref="INodeTypeProvider"/> and /// <see cref="IExpressionTreeProcessor"/> implementation. /// </summary> /// <param name="nodeTypeProvider">The <see cref="INodeTypeProvider"/> to use when parsing <see cref="Expression"/> trees. Use /// <see cref="CreateDefaultNodeTypeProvider"/> to create an instance of <see cref="CompoundNodeTypeProvider"/> that already includes all /// default node types. (The <see cref="CompoundNodeTypeProvider"/> can be customized as needed by adding or removing /// <see cref="CompoundNodeTypeProvider.InnerProviders"/>).</param> /// <param name="processor">The <see cref="IExpressionTreeProcessor"/> to apply to <see cref="Expression"/> trees before parsing their nodes. Use /// <see cref="CreateDefaultProcessor"/> to create an instance of <see cref="CompoundExpressionTreeProcessor"/> that already includes /// the default steps. (The <see cref="CompoundExpressionTreeProcessor"/> can be customized as needed by adding or removing /// <see cref="CompoundExpressionTreeProcessor.InnerProcessors"/>).</param> public ExpressionTreeParser (INodeTypeProvider nodeTypeProvider, IExpressionTreeProcessor processor) { ArgumentUtility.CheckNotNull ("nodeTypeProvider", nodeTypeProvider); ArgumentUtility.CheckNotNull ("processor", processor); _nodeTypeProvider = nodeTypeProvider; _processor = processor; _methodCallExpressionParser = new MethodCallExpressionParser (_nodeTypeProvider); }
public void SetUp() { _stepMock1 = MockRepository.GenerateStrictMock <IExpressionTreeProcessor> (); _stepMock2 = MockRepository.GenerateStrictMock <IExpressionTreeProcessor> (); _compoundExpressionTreeProcessor = new CompoundExpressionTreeProcessor(new[] { _stepMock1, _stepMock2 }); }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionTreeParser"/> class with a custom <see cref="INodeTypeProvider"/> and /// <see cref="IExpressionTreeProcessor"/> implementation. /// </summary> /// <param name="nodeTypeProvider">The <see cref="INodeTypeProvider"/> to use when parsing <see cref="Expression"/> trees. Use /// <see cref="CreateDefaultNodeTypeProvider"/> to create an instance of <see cref="CompoundNodeTypeProvider"/> that already includes all /// default node types. (The <see cref="CompoundNodeTypeProvider"/> can be customized as needed by adding or removing /// <see cref="CompoundNodeTypeProvider.InnerProviders"/>).</param> /// <param name="processor">The <see cref="IExpressionTreeProcessor"/> to apply to <see cref="Expression"/> trees before parsing their nodes. Use /// <see cref="CreateDefaultProcessor"/> to create an instance of <see cref="CompoundExpressionTreeProcessor"/> that already includes /// the default steps. (The <see cref="CompoundExpressionTreeProcessor"/> can be customized as needed by adding or removing /// <see cref="CompoundExpressionTreeProcessor.InnerProcessors"/>).</param> public ExpressionTreeParser(INodeTypeProvider nodeTypeProvider, IExpressionTreeProcessor processor) { _nodeTypeProvider = nodeTypeProvider; _processor = processor; _methodCallExpressionParser = new MethodCallExpressionParser(_nodeTypeProvider); }
public void SetUp () { _stepMock1 = MockRepository.GenerateStrictMock<IExpressionTreeProcessor> (); _stepMock2 = MockRepository.GenerateStrictMock<IExpressionTreeProcessor> (); _compoundExpressionTreeProcessor = new CompoundExpressionTreeProcessor (new[] { _stepMock1, _stepMock2 }); }