private QueryClause VisitSelectMany(MethodCallExpression node, LambdaExpression selector, LambdaExpression projector) { if (projector != selector) { Type transparentType = projector.ReturnType; if (transparentType.IsCompilerGenerated()) { // from {item1} in {collection1} // from {item2} in {collection2} ParameterExpression firstVar = GetVariable(projector.Parameters[0]); ParameterExpression secondVar = GetVariable(projector.Parameters[1]); _clauses.Add(Expressive.From(firstVar, node.Arguments[0])); return(Expressive.From(secondVar, selector.Body)); } else { // from {item} in {collection} // select {item} ParameterExpression newItem = GetVariable(projector.Parameters[1]); _clauses.Add(Expressive.From(newItem, selector.Body)); return(Expressive.Select(projector.Body)); } } return(null); }
/// <inheritdoc /> public override Expression VisitLockStatement(ILockStatement operation, LocalBinder argument) { return(Expressive.Lock( operation.LockedObject.Accept(this, argument), operation.Body.Accept(this, argument) )); }
/// <inheritdoc /> public override Expression VisitQueryExpression(QueryExpressionSyntax node) { return(Expressive.Query( Enumerable.Repeat(VisitContinuationClause(node.FromClause), 1) .Concat(VisitLinqBody(node.Body)) )); }
/// <inheritdoc /> public override Expression VisitUsingStatement(IUsingStatement operation, LocalBinder argument) { // TODO: Declarations in new binder return(Expressive.Using( Visit(operation.Declaration ?? operation.Value, argument), operation.Body.Accept(this, argument) )); }
/// <inheritdoc /> protected override Expression Reduce(QueryClause previous, QueryClause next) { return(Expressive.ForEach( Variable, Enumerable, next.Reduce() )); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public OrderByClause Update(IEnumerable <OrderingExpression> orderings) { if (orderings.SequenceEqual(Orderings)) { return(this); } return(Expressive.OrderBy(orderings)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public LockExpression Update(Expression obj, Expression body) { if (body == Body && obj == Object) { return(this); } return(Expressive.Lock(obj, body)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public WhereClause Update(Expression condition) { if (Condition == condition) { return(this); } return(Expressive.Where(condition)); }
/// <inheritdoc cref="UnaryExpression.Update(System.Linq.Expressions.Expression)" select="summary"/> public AwaitExpression Update(Expression task, MethodInfo method) { if (Expression == task && Equals(Method, method)) { return(this); } return(Expressive.Await(task, method)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public SelectClause Update(Expression expression) { if (Selector == expression) { return(this); } return(Expressive.Select(expression)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public FromClause Update(ParameterExpression variable, Expression enumerable) { if (Variable == variable && Enumerable == enumerable) { return(this); } return(Expressive.From(variable, enumerable)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public GroupByClause Update(ParameterExpression variable, Expression selector) { if (Variable == variable && Selector == selector) { return(this); } return(Expressive.GroupBy(variable, selector)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public JoinClause Update(ParameterExpression variable, Expression enumerable, Expression left, Expression right) { if (Variable == variable && Enumerable == enumerable && Left == left && Right == right) { return(this); } return(Expressive.Join(variable, enumerable, left, right)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public LetClause Update(ParameterExpression variable, Expression expression) { if (Variable == variable && Expression == expression) { return(this); } return(Expressive.Let(variable, expression)); }
private QueryClause VisitWhere(MethodCallExpression node, LambdaExpression predicate) { if (_clauses.Count == 0) { _clauses.Add(Expressive.From(GetVariable(predicate.Parameters[0]), node.Arguments[0])); } return(Expressive.Where(predicate.Body)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public ForExpression Update(ParameterExpression variable, Expression initializer, Expression test, Expression step, Expression body, LabelTarget breakTarget, LabelTarget continueTarget) { if (Variable == variable && Initializer == initializer && Test == test && Step == step && Body == body && BreakLabel == breakTarget && ContinueLabel == continueTarget) { return(this); } return(Expressive.For(variable, initializer, test, step, body, breakTarget, continueTarget)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public ForEachExpression Update(ParameterExpression variable, Expression enumerable, Expression body, LabelTarget breakTarget, LabelTarget continueTarget) { if (this.Variable == variable && this.Enumerable == enumerable && this.Body == body && BreakLabel == breakTarget && ContinueLabel == continueTarget) { return(this); } return(Expressive.ForEach(variable, enumerable, body, breakTarget, continueTarget)); }
private QueryClause VisitOrderBy(MethodCallExpression node, LambdaExpression lambda, bool descending) { if (_clauses.Count == 0) { _clauses.Add(Expressive.From(GetVariable(lambda.Parameters[1]), node.Arguments[0])); } return(Expressive.OrderBy(lambda.Body, !descending)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public AsyncExpression Update(Expression body) { if (Body == body) { return(this); } return(Expressive.Async(body)); }
/// <inheritdoc /> public override Expression VisitWhileUntilLoopStatement(IWhileUntilLoopStatement operation, LocalBinder argument) { Expression condition = operation.Condition.Accept(this, argument); Expression body = operation.Body.Accept(this, argument); return(operation.IsTopTest ? Expressive.While(condition, body) as Expression : Expressive.DoWhile(condition, body)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public QueryExpression Update(params QueryClause[] clauses) { if (Clauses.SequenceEqual(clauses)) { return(this); } return(Expressive.Query(clauses)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public DoWhileExpression Update(Expression test, Expression body, LabelTarget breakTarget, LabelTarget continueTarget) { if (Test == test && Body == body && BreakLabel == breakTarget && ContinueLabel == continueTarget) { return(this); } return(Expressive.DoWhile(test, body, breakTarget, continueTarget)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public UsingExpression Update(ParameterExpression variable, Expression disposable, Expression body) { if (Variable == variable && Disposable == disposable && Body == body) { return(this); } return(Expressive.Using(variable, disposable, body)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public IteratorExpression Update(Expression iterator) { if (Iterator == iterator) { return(this); } return(Expressive.Iterator(iterator)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public TypeOfExpression Update(Type type) { if (TargetType == type) { return(this); } return(Expressive.TypeOf(type)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public WhileExpression Update(Expression test, Expression body, LabelTarget breakTarget, LabelTarget continueTarget) { if (test == Test && body == Body && breakTarget == BreakLabel && continueTarget == ContinueLabel) { return(this); } return(Expressive.While(test, body, breakTarget, continueTarget)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public TypeExpression Update(Type type) { if (Type == type) { return(this); } return(Expressive.Type(type)); }
/// <inheritdoc cref="UnaryExpression.Update(System.Linq.Expressions.Expression)" select="summary"/> public YieldExpression Update(Expression value) { if (Expression == value) { return(this); } return(Expressive.Yield(value)); }
/// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/> public GroupByIntoClause Update(ParameterExpression variable, Expression selector, ParameterExpression group) { if (Variable == variable && Selector == selector && Group == group) { return(this); } return(Expressive.GroupBy(variable, selector, group)); }
/// <inheritdoc /> public override Expression VisitForEachLoopStatement(IForEachLoopStatement operation, LocalBinder argument) { ParameterExpression variable = VisitLocal(operation.IterationVariable); LocalBinder binder = argument.Child(operation.IterationVariable, variable); return(Expressive.ForEach(variable, operation.Collection.Accept(this, argument), operation.Body.Accept(this, binder) )); }