/// <summary> /// Converts to serializable. /// </summary> /// <param name="unaryExpression">The unary expression.</param> /// <returns> /// Serializable expression. /// </returns> public static UnaryExpressionRepresentation ToRepresentation( this UnaryExpression unaryExpression) { if (unaryExpression == null) { throw new ArgumentNullException(nameof(unaryExpression)); } var type = unaryExpression.Type.ToRepresentation(); var nodeType = unaryExpression.NodeType; var operand = unaryExpression.Operand.ToRepresentation(); var result = new UnaryExpressionRepresentation(type, nodeType, operand); return(result); }
/// <summary> /// From the serializable. /// </summary> /// <param name="unaryExpressionRepresentation">The unary expression.</param> /// <returns> /// Converted expression. /// </returns> public static Expression FromRepresentation( this UnaryExpressionRepresentation unaryExpressionRepresentation) { if (unaryExpressionRepresentation == null) { throw new ArgumentNullException(nameof(unaryExpressionRepresentation)); } var nodeType = unaryExpressionRepresentation.NodeType; switch (nodeType) { case ExpressionType.UnaryPlus: return(Expression.UnaryPlus(unaryExpressionRepresentation.Operand.FromRepresentation())); default: return(Expression.MakeUnary(nodeType, unaryExpressionRepresentation.Operand.FromRepresentation(), unaryExpressionRepresentation.Type.ResolveFromLoadedTypes())); } }