private Expression Expand(Expression visited) { if (expander == null) { return(visited); } var expanded = expander.Expand(context); var callback = context.AfterNestedVisitCallback; context.AfterNestedVisitCallback = null; if (expanded != null && expanded != visited) { if (!visited.Type.IsAssignableFrom(expanded.Type)) { throw new InvalidOperationException(Resources.ExpanderCannotChangeExpressionType); } context.PushVisitedNode(null); expanded = Visit(expanded); context.PopVisitedNode(); if (callback != null) { callback(); } return(expanded); } return(visited); }
private Expression Expand(Expression visited) { if (this.expander == null) { this.expander = this.context.QueryContext .GetApiService <IQueryExpressionExpander>(); } if (expander == null) { return(visited); } var expanded = expander.Expand(this.context); var callback = this.context.AfterNestedVisitCallback; this.context.AfterNestedVisitCallback = null; if (expanded != null && expanded != visited) { if (!visited.Type.IsAssignableFrom(expanded.Type)) { throw new InvalidOperationException( Resources.ExpanderCannotChangeExpressionType); } this.context.PushVisitedNode(null); expanded = this.Visit(expanded); this.context.PopVisitedNode(); if (callback != null) { callback(); } return(expanded); } return(visited); }