We're updating the issue view to help you get more done. 

The code required to create a customized query parser has changed (MethodCallExpressionNodeTypeRegistry, IExpressionTreeProcessingStep, ExpressionTreeParser)

Description

The MethodCallExpressionNodeTypeRegistry has been replaced by an interface with three implementations: INodeTypeProvider, MethodInfoBasedNodeTypeRegistry, MethodNameBasedNodeTypeRegistry, and CompoundNodeTypeProvider. The MethodCallExpressionNodeTypeRegistry.CreateDefault method has been replaced by ExpressionTreeParser.CreateDefaultNodeTypeProvider, which now creates a CompoundNodeTypeProvider holding default instances of MethodInfoBasedNodeTypeRegistry and MethodNameBasedNodeTypeRegistry. Change the defaults by adding, inserting, or removing instances to/from the default CompoundNodeTypeProvider (see below).

The IExpressionTreeProcessingStep interface is now called IExpressionTreeProcessor. Instead of an array of IExpressionTreeProcessors, ExpressionTreeParser now accepts a single IExpressionTreeProcessor (which can be a CompoundExpressionTreeProcessor if more than one processor is needed). The ExpressionTreeParser.CreateDefaultProcessor() method creates an instance of CompoundExpressionTreeProcessor with partial evaluation and transformation steps already included. Change the defaults by adding, inserting, or removing instances to/from the default CompoundExpressionTreeProcessor.

Here is the recommended new way of creating a customized query parser:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 private static IQueryParser CreateQueryParser () { var customNodeTypeRegistry = new MethodInfoBasedNodeTypeRegistry(); // Register custom node parsers here: // customNodeTypeRegistry.Register (MyExpressionNode.SupportedMethods, typeof (MyExpressionNode)); // Alternatively, use the CreateFromTypes factory method. // Use MethodNameBasedNodeTypeRegistry to register parsers by query operator name instead of MethodInfo. var nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider (); nodeTypeProvider.InnerProviders.Add (customNodeTypeRegistry); var transformerRegistry = ExpressionTransformerRegistry.CreateDefault (); // Register custom expression transformers executed _after_ partial evaluation here (this should be the default): // transformerRegistry.Register (new MyExpressionTransformer()); var processor = ExpressionTreeParser.CreateDefaultProcessor (transformerRegistry); // To register custom expression transformers executed _before_ partial evaluation, use this code: // var earlyTransformerRegistry = new ExpressionTransformerRegistry(); // earlyTransformerRegistry.Register (new MyEarlyExpressionTransformer()); // processor.InnerProcessors.Insert (0, new TransformingExpressionTreeProcessor (tranformationProvider)); // Add custom processors here (use Insert (0, ...) to add at the beginning): // processor.InnerProcessors.Add (new MyExpressionTreeProcessor()); var expressionTreeParser = new ExpressionTreeParser (nodeTypeProvider, processor); var queryParser = new QueryParser (expressionTreeParser); return queryParser; }

These changes were made in order to provide a more consistent and extensible design.

Status

Assignee

Fabian Schmied

Reporter

Fabian Schmied

Labels

Time tracking

0m

Components

Fix versions

Priority

Normal