/// <summary> /// Visits a JSON expression tree array node. /// </summary> /// <param name="node">JSON expression tree array node to visit.</param> /// <returns>Copy of the expression tree node.</returns> public override Expression VisitArray(ArrayExpression node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } var elements = default(Expression[]); var n = node.ElementCount; for (var i = 0; i < n; i++) { var oldElement = node.GetElement(i); var newElement = Visit(oldElement); if (elements != null) { elements[i] = newElement; } else { if (oldElement != newElement) { elements = new Expression[n]; for (var j = 0; j < i; j++) { elements[j] = node.GetElement(j); } elements[i] = newElement; } } } if (elements != null) { return(Expression.Array(elements)); } return(node); }