Ejemplo n.º 1
0
            protected override Expression VisitParameter(ParameterExpression node)
            {
                object argument;

                if (parameterMappings.TryGetValue(node.Name, out argument))
                {
                    if (ReflectionHelper.IsInstanceOf(node.Type, argument))
                    {
                        return(Expression.Constant(argument, node.Type));
                    }
                    else
                    {
                        INotifyExpression expression = argument as INotifyExpression;
                        if (expression != null && expression.IsConstant)
                        {
                            return(Expression.Constant(expression.ValueObject, node.Type));
                        }
                        else
                        {
                            var notifyValueType = typeof(INotifyValue <>).MakeGenericType(node.Type);
                            if (notifyValueType.IsInstanceOfType(argument))
                            {
                                return(Expression.MakeMemberAccess(Expression.Constant(argument, notifyValueType), ReflectionHelper.GetProperty(notifyValueType, "Value")));
                            }
                        }
                    }
                }
                return(node);
            }