Наследование: IMvxParsedExpression
Пример #1
0
        private static Expression ParseProperty(Expression current, MvxParsedExpression toReturn)
        {
            var me = (MemberExpression)current;

            toReturn.PrependProperty(me.Member.Name);
            current = me.Expression;
            return(current);
        }
Пример #2
0
        private static IMvxParsedExpression ParseBindExtensionMethod(LambdaExpression propertyPath, object controlType)
        {
            var compiled            = propertyPath.Compile();
            var virtualPropertyName = compiled.DynamicInvoke(controlType) as string;

            var toReturn = new MvxParsedExpression();

            toReturn.PrependProperty(virtualPropertyName);
            return(toReturn);
        }
Пример #3
0
        public IMvxParsedExpression Parse(LambdaExpression propertyPath)
        {
            var toReturn = new MvxParsedExpression();

            var current = propertyPath.Body;

            while (current != null &&
                   current.NodeType != ExpressionType.Parameter)
            {
                current = ParseTo(current, toReturn);
            }

            return(toReturn);
        }
Пример #4
0
        private static Expression ParseMethodCall(Expression current, MvxParsedExpression toReturn)
        {
            var me = (MethodCallExpression)current;

            if (me.Method.Name != "get_Item" ||
                me.Arguments.Count != 1)
            {
                throw new ArgumentException(
                          "Property expression must be of the form 'x => x.SomeProperty.SomeOtherProperty' or 'x => x.SomeCollection[0].Property'");
            }
            var argument = me.Arguments[0];

            argument = ConvertMemberAccessToConstant(argument);
            toReturn.PrependIndexed(argument.ToString());
            current = me.Object;
            return(current);
        }
Пример #5
0
        private static Expression ParseTo(Expression current, MvxParsedExpression toReturn)
        {
            // This happens when a value type gets boxed
            if (current.NodeType == ExpressionType.Convert || current.NodeType == ExpressionType.ConvertChecked)
            {
                return(Unbox(current));
            }

            if (current.NodeType == ExpressionType.MemberAccess)
            {
                return(ParseProperty(current, toReturn));
            }

            if (current is MethodCallExpression)
            {
                return(ParseMethodCall(current, toReturn));
            }

            throw new ArgumentException(
                      "Property expression must be of the form 'x => x.SomeProperty.SomeOtherProperty'");
        }