public Expression RemoveOuterParameter(Dictionary <Expression, Expression> processedExpressions) { Func <Expression, Expression> genericRemover = e => GenericExpressionVisitor <IMappedExpression> .Process(e, mapped => mapped.RemoveOuterParameter(processedExpressions)); var result = new ConstructorExpression( Type, Bindings.ToDictionary(kvp => kvp.Key, kvp => genericRemover(kvp.Value)), NativeBindings = NativeBindings.ToDictionary(kvp => kvp.Key, kvp => genericRemover(kvp.Value)), Constructor, ConstructorArguments.Select(genericRemover).ToList()); return(result); }
public Expression Remap(int offset, Dictionary <Expression, Expression> processedExpressions) { Func <IMappedExpression, Expression> remapper = delegate(IMappedExpression mapped) { var parametrizedExpression = mapped as ParameterizedExpression; if (parametrizedExpression != null && (parametrizedExpression.OuterParameter == OuterParameter || OuterParameter == null)) { return(mapped.Remap(offset, new Dictionary <Expression, Expression>())); } return((Expression)mapped); }; var newBindings = Bindings.ToDictionary(kvp => kvp.Key, kvp => GenericExpressionVisitor <IMappedExpression> .Process(kvp.Value, remapper)); var newConstructorArguments = ConstructorArguments.Select(arg => GenericExpressionVisitor <IMappedExpression> .Process(arg, remapper)); var newNativeBindings = NativeBindings.ToDictionary(kvp => kvp.Key, kvp => GenericExpressionVisitor <IMappedExpression> .Process(kvp.Value, remapper)); var result = new ConstructorExpression( Type, newBindings, newNativeBindings, Constructor, newConstructorArguments); return(result); }