コード例 #1
0
        /// <summary>
        /// Visits a <see cref="SerializableNewArrayExpression"/>.
        /// </summary>
        /// <param name="expression"><see cref="SerializableNewArrayExpression"/> to visit.</param>
        /// <returns>Returns the converted <see cref="Expression"/>.</returns>
        protected override Expression VisitSerializableNewArrayExpression(SerializableNewArrayExpression expression)
        {
            if (expression.NodeType == ExpressionType.NewArrayBounds)
            {
                return(Expression.NewArrayBounds((Type)expression.Type.GetClrVersion(), VisitCollection <Expression>(expression.Expressions)));
            }
            Type t = (Type)expression.Type.GetClrVersion();

            // Expression must be an Array
            Debug.Assert(t.HasElementType);

            return(Expression.NewArrayInit(t.GetElementType(), VisitCollection <Expression>(expression.Expressions)));
        }
        private Expression VisitNewArray(SerializableNewArrayExpression na)
        {
            switch (na.NodeType)
            {
            case ExpressionType.NewArrayInit:
                return(Expression.NewArrayInit(na.Type.GetElementType(), VisitExpressionSequence(na.Expressions)));

            case ExpressionType.NewArrayBounds:
                return(Expression.NewArrayBounds(na.Type.GetElementType(), VisitExpressionSequence(na.Expressions)));

            default:
                throw new ArgumentException();
            }
        }
コード例 #3
0
        /// <summary>
        /// Visits a <see cref="SerializableNewArrayExpression"/>.
        /// </summary>
        /// <param name="expression"><see cref="SerializableNewArrayExpression"/> to visit.</param>
        /// <returns>Returns the converted <see cref="Expression"/>.</returns>
        protected override Expression VisitSerializableNewArrayExpression(SerializableNewArrayExpression expression)
        {
            if (expression.NodeType == ExpressionType.NewArrayBounds)
            {
#if !NETFX_CORE
                return(Expression.NewArrayBounds((Type)expression.Type.GetClrVersion(), VisitCollection <Expression>(expression.Expressions)));
#else
                return(Expression.NewArrayBounds(((TypeInfo)expression.Type.GetClrVersion()).AsType(), VisitCollection <Expression>(expression.Expressions)));
#endif
            }
#if !NETFX_CORE
            Type t = (Type)expression.Type.GetClrVersion();
#else
            Type t = ((TypeInfo)expression.Type.GetClrVersion()).AsType();
#endif
            // Expression must be an Array
            Debug.Assert(t.HasElementType);

            return(Expression.NewArrayInit(t.GetElementType(), VisitCollection <Expression>(expression.Expressions)));
        }
コード例 #4
0
 /// <summary>
 /// Visits a <see cref="SerializableNewArrayExpression"/>.
 /// </summary>
 /// <param name="expression"><see cref="SerializableNewArrayExpression"/> to visit.</param>
 /// <returns>Returns the converted <see cref="Expression"/>.</returns>
 protected abstract Expression VisitSerializableNewArrayExpression(SerializableNewArrayExpression expression);