public override void SetUp() { base.SetUp(); _source2 = Expression.Constant(new[] { "test1", "test2" }); _node = new ConcatExpressionNode( CreateParseInfo(SourceNode, "u", ReflectionUtility.GetMethod(() => Queryable.Concat <int> (null, null))), _source2); }
public override void SetUp() { base.SetUp(); _source2 = Expression.Constant(new[] { "test1", "test2" }); _node = new ConcatExpressionNode( CreateParseInfo(SourceNode, "u", ConcatExpressionNode.SupportedMethods[0].MakeGenericMethod(typeof(int))), _source2); }
public void GetSupportedMethods() { Assert.That( ConcatExpressionNode.GetSupportedMethods(), Is.EquivalentTo( new[] { GetGenericMethodDefinition(() => Queryable.Concat <object> (null, null)), GetGenericMethodDefinition(() => Enumerable.Concat <object> (null, null)) })); }
/// <summary> /// Creates a <see cref="MethodInfoBasedNodeTypeRegistry"/> and registers all relevant <see cref="IExpressionNode"/> implementations in the <b>Remotion.Linq</b> assembly. /// </summary> /// <returns> /// A <see cref="MethodInfoBasedNodeTypeRegistry"/> with all <see cref="IExpressionNode"/> types in the <b>Remotion.Linq</b> assembly registered. /// </returns> public static MethodInfoBasedNodeTypeRegistry CreateFromRelinqAssembly() { var registry = new MethodInfoBasedNodeTypeRegistry(); registry.Register(AggregateExpressionNode.GetSupportedMethods(), typeof(AggregateExpressionNode)); registry.Register(AggregateFromSeedExpressionNode.GetSupportedMethods(), typeof(AggregateFromSeedExpressionNode)); registry.Register(AllExpressionNode.GetSupportedMethods(), typeof(AllExpressionNode)); registry.Register(AnyExpressionNode.GetSupportedMethods(), typeof(AnyExpressionNode)); registry.Register(AsQueryableExpressionNode.GetSupportedMethods(), typeof(AsQueryableExpressionNode)); registry.Register(AverageExpressionNode.GetSupportedMethods(), typeof(AverageExpressionNode)); registry.Register(CastExpressionNode.GetSupportedMethods(), typeof(CastExpressionNode)); registry.Register(ConcatExpressionNode.GetSupportedMethods(), typeof(ConcatExpressionNode)); registry.Register(ContainsExpressionNode.GetSupportedMethods(), typeof(ContainsExpressionNode)); registry.Register(CountExpressionNode.GetSupportedMethods(), typeof(CountExpressionNode)); registry.Register(DefaultIfEmptyExpressionNode.GetSupportedMethods(), typeof(DefaultIfEmptyExpressionNode)); registry.Register(DistinctExpressionNode.GetSupportedMethods(), typeof(DistinctExpressionNode)); registry.Register(ExceptExpressionNode.GetSupportedMethods(), typeof(ExceptExpressionNode)); registry.Register(FirstExpressionNode.GetSupportedMethods(), typeof(FirstExpressionNode)); registry.Register(GroupByExpressionNode.GetSupportedMethods(), typeof(GroupByExpressionNode)); registry.Register(GroupByWithResultSelectorExpressionNode.GetSupportedMethods(), typeof(GroupByWithResultSelectorExpressionNode)); registry.Register(GroupJoinExpressionNode.GetSupportedMethods(), typeof(GroupJoinExpressionNode)); registry.Register(IntersectExpressionNode.GetSupportedMethods(), typeof(IntersectExpressionNode)); registry.Register(JoinExpressionNode.GetSupportedMethods(), typeof(JoinExpressionNode)); registry.Register(LastExpressionNode.GetSupportedMethods(), typeof(LastExpressionNode)); registry.Register(LongCountExpressionNode.GetSupportedMethods(), typeof(LongCountExpressionNode)); registry.Register(MaxExpressionNode.GetSupportedMethods(), typeof(MaxExpressionNode)); registry.Register(MinExpressionNode.GetSupportedMethods(), typeof(MinExpressionNode)); registry.Register(OfTypeExpressionNode.GetSupportedMethods(), typeof(OfTypeExpressionNode)); registry.Register(OrderByDescendingExpressionNode.GetSupportedMethods(), typeof(OrderByDescendingExpressionNode)); registry.Register(OrderByExpressionNode.GetSupportedMethods(), typeof(OrderByExpressionNode)); registry.Register(ReverseExpressionNode.GetSupportedMethods(), typeof(ReverseExpressionNode)); registry.Register(SelectExpressionNode.GetSupportedMethods(), typeof(SelectExpressionNode)); registry.Register(SelectManyExpressionNode.GetSupportedMethods(), typeof(SelectManyExpressionNode)); registry.Register(SingleExpressionNode.GetSupportedMethods(), typeof(SingleExpressionNode)); registry.Register(SkipExpressionNode.GetSupportedMethods(), typeof(SkipExpressionNode)); registry.Register(SumExpressionNode.GetSupportedMethods(), typeof(SumExpressionNode)); registry.Register(TakeExpressionNode.GetSupportedMethods(), typeof(TakeExpressionNode)); registry.Register(ThenByDescendingExpressionNode.GetSupportedMethods(), typeof(ThenByDescendingExpressionNode)); registry.Register(ThenByExpressionNode.GetSupportedMethods(), typeof(ThenByExpressionNode)); registry.Register(UnionExpressionNode.GetSupportedMethods(), typeof(UnionExpressionNode)); registry.Register(WhereExpressionNode.GetSupportedMethods(), typeof(WhereExpressionNode)); return(registry); }
/// <summary> /// Create the parser we want to use to parse the LINQ query. If we need to add /// some operators or other custom things into the parser, this is where it is done. /// See https://www.re-motion.org/jira/browse/RM-3724 for sample code. /// </summary> internal static IQueryParser CreateLINQToTTreeParser() { // // Provider for our classes, and they also go into the whole pot of soup // var mreg = new MethodInfoBasedNodeTypeRegistry(); mreg.Register(UniqueCombinationsExpressionNode.SupportedMethods, typeof(UniqueCombinationsExpressionNode)); mreg.Register(PairWiseAllExpressionNode.SupportedMethods, typeof(PairWiseAllExpressionNode)); mreg.Register(AsQueriableExpressionNode.SupportedMethods, typeof(AsQueriableExpressionNode)); mreg.Register(AsCSVExpressionNode.SupportedMethods, typeof(AsCSVExpressionNode)); mreg.Register(AsTTreeExpressionNode.SupportedMethods, typeof(AsTTreeExpressionNode)); mreg.Register(ConcatExpressionNode.GetSupportedMethods(), typeof(ConcatExpressionNode)); mreg.Register(TakeSkipExpressionNode.SupportedMethods, typeof(TakeSkipExpressionNode)); var defaultNodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider(); var newProvider = new CompoundNodeTypeProvider(new INodeTypeProvider[] { mreg, defaultNodeTypeProvider }); // // All the various transformers we need... // var transformerRegistry = ExpressionTransformerRegistry.CreateDefault(); transformerRegistry.Register(new PropertyExpressionTransformer()); transformerRegistry.Register(new EnumerableRangeExpressionTransformer()); transformerRegistry.Register(new CreateTupleExpressionTransformer()); transformerRegistry.Register <MethodCallExpression>(new ExpressionVariableInvokeExpressionTransformer(new ExpressionType[] { ExpressionType.Call })); transformerRegistry.Register <InvocationExpression>(new ExpressionVariableInvokeExpressionTransformer(new ExpressionType[] { ExpressionType.Invoke })); // // Create the query provider // var expressionTreeParser = new ExpressionTreeParser( newProvider, ExpressionTreeParser.CreateDefaultProcessor(transformerRegistry)); return(new QueryParser(expressionTreeParser)); }