示例#1
0
        /// <summary>
        /// From the serializable.
        /// </summary>
        /// <param name="listInitExpressionRepresentation">The listInit expression.</param>
        /// <returns>
        /// Converted expression.
        /// </returns>
        public static ListInitExpression FromRepresentation(this ListInitExpressionRepresentation listInitExpressionRepresentation)
        {
            if (listInitExpressionRepresentation == null)
            {
                throw new ArgumentNullException(nameof(listInitExpressionRepresentation));
            }

            var result = Expression.ListInit(
                listInitExpressionRepresentation.NewExpressionRepresentation.FromRepresentation(),
                listInitExpressionRepresentation.Initializers.FromRepresentation().ToArray());

            return(result);
        }
示例#2
0
        /// <summary>
        /// Converts to serializable.
        /// </summary>
        /// <param name="listInitExpression">The listInit expression.</param>
        /// <returns>
        /// Serializable expression.
        /// </returns>
        public static ListInitExpressionRepresentation ToRepresentation(
            this ListInitExpression listInitExpression)
        {
            if (listInitExpression == null)
            {
                throw new ArgumentNullException(nameof(listInitExpression));
            }

            var type = listInitExpression.Type.ToRepresentation();

            var newExpression = listInitExpression.NewExpression.ToRepresentation();

            var initializers = listInitExpression.Initializers.ToRepresentation();

            var result = new ListInitExpressionRepresentation(type, newExpression, initializers);

            return(result);
        }