Exemplo n.º 1
0
        public void GetArgumentTypes()
        {
            var arguments =
                new Expression[] { Expression.Constant(""), Expression.Parameter(typeof(double)), Expression.Parameter(typeof(int).MakeByRefType()) };

            var result = BodyContextUtility.GetArgumentTypes(arguments.AsOneTime());

            Assert.That(result, Is.EqualTo(new[] { typeof(string), typeof(double), typeof(int).MakeByRefType() }));
        }
        public Expression CreateCallExpression(JoinPoint joinPoint, ParameterExpression context)
        {
            var arguments = joinPoint.Method.GetParameters().Select((x, i) => _valueMapper.GetIndexMapping(context, i));
            var call      = joinPoint.Method.Body;

            if (call is OriginalBodyExpression)
            {
                call = Expression.Call(joinPoint.This, new NonVirtualCallMethodInfoAdapter(joinPoint.Method.UnderlyingSystemMethodInfo), arguments);
            }
            else
            {
                call = BodyContextUtility.ReplaceParameters(joinPoint.Method.ParameterExpressions, call, arguments);
            }
            //call = call.

            if (joinPoint.Method.ReturnType != typeof(void))
            {
                var returnValue = _valueMapper.GetReturnMapping(context);
                call = Expression.Assign(returnValue, call);
            }

            return(call);
        }
Exemplo n.º 3
0
 private Expression CallReplaceParameters(params Expression[] arguments)
 {
     return(BodyContextUtility.ReplaceParameters(_parameters.AsOneTime(), _previousBody, arguments.AsOneTime()));
 }