Exemple #1
0
        /// <summary>
        /// From the serializable.
        /// </summary>
        /// <param name="conditionalExpressionRepresentation">The conditional expression.</param>
        /// <returns>
        /// Converted expression.
        /// </returns>
        public static ConditionalExpression FromRepresentation(
            this ConditionalExpressionRepresentation conditionalExpressionRepresentation)
        {
            if (conditionalExpressionRepresentation == null)
            {
                throw new ArgumentNullException(nameof(conditionalExpressionRepresentation));
            }

            var result = Expression.Condition(
                conditionalExpressionRepresentation.Test.FromRepresentation(),
                conditionalExpressionRepresentation.IfTrue.FromRepresentation(),
                conditionalExpressionRepresentation.IfFalse.FromRepresentation());

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Converts to serializable.
        /// </summary>
        /// <param name="conditionalExpression">The conditional expression.</param>
        /// <returns>
        /// Serializable expression.
        /// </returns>
        public static ConditionalExpressionRepresentation ToRepresentation(
            this ConditionalExpression conditionalExpression)
        {
            if (conditionalExpression == null)
            {
                throw new ArgumentNullException(nameof(conditionalExpression));
            }

            var type = conditionalExpression.Type.ToRepresentation();

            var nodeType = conditionalExpression.NodeType;

            var test = conditionalExpression.Test.ToRepresentation();

            var expressionIfTrue = conditionalExpression.IfTrue.ToRepresentation();

            var expressionIfFalse = conditionalExpression.IfFalse.ToRepresentation();

            var result = new ConditionalExpressionRepresentation(type, nodeType, test, expressionIfTrue, expressionIfFalse);

            return(result);
        }