Example #1
0
        public UserInputExpressionParts GetUserInputParts(Expression inputExpressionBody)
        {
            UserInputExpressionParts result = null;

            if (specificParsers.Any(p => p.TryGetParts(inputExpressionBody, out result)))
            {
                return(result);
            }

            throw new FlashMapperBadInputException($"Mapping expression has incorrect format. Expression of type {inputExpressionBody?.NodeType} is not supported.");
        }
Example #2
0
        public bool TryGetParts(Expression inputExpressionBody, out UserInputExpressionParts parts)
        {
            var memberInitExpression = inputExpressionBody as MemberInitExpression;

            if (memberInitExpression == null || memberInitExpression.NodeType != ExpressionType.MemberInit)
            {
                parts = null;
                return(false);
            }
            parts = new UserInputExpressionParts
            {
                Bindings = memberInitExpression.Bindings.ToArray(),
                ModelCreateExpression = memberInitExpression.NewExpression
            };
            return(true);
        }
        public bool TryGetParts(Expression inputExpressionBody, out UserInputExpressionParts parts)
        {
            var newExpression = inputExpressionBody as NewExpression;

            if (newExpression == null || newExpression.NodeType != ExpressionType.New)
            {
                parts = null;
                return(false);
            }
            parts = new UserInputExpressionParts
            {
                Bindings = new MemberBinding[0],
                ModelCreateExpression = newExpression
            };
            return(true);
        }