public void CreateFromMemberName() { var memberInfo = typeof(Cook).GetProperty("Name"); var innerExpression = Expression.Constant("inner"); var result = NamedExpression.CreateFromMemberName(memberInfo.Name, innerExpression); Assert.That(result.Name, Is.SameAs(memberInfo.Name)); Assert.That(result.Expression, Is.SameAs(innerExpression)); }
protected override Expression VisitMethodCall(MethodCallExpression expression) { ArgumentUtility.CheckNotNull("expression", expression); var transformer = _methodCallTransformerProvider.GetTransformer(expression); if (transformer != null) { var transformedExpression = transformer.Transform(expression); return(Visit(transformedExpression)); } var namedInstance = expression.Object != null?NamedExpression.CreateFromMemberName("Object", Visit (expression.Object)) : null; var namedArguments = expression.Arguments.Select((a, i) => (Expression)NamedExpression.CreateFromMemberName("Arg" + i, Visit(a))); return(Expression.Call(namedInstance, expression.Method, namedArguments)); }