/// <summary> /// Visits the children of the given payload element and replaces it with a copy if any child changes /// </summary> /// <param name="payloadElement">The payload element to potentially replace</param> /// <returns>The original element or a copy to replace it with</returns> public virtual ODataPayloadElement Visit(PrimitiveMultiValueProperty payloadElement) { ExceptionUtilities.CheckArgumentNotNull(payloadElement, "payloadElement"); var replacedCollection = this.Recurse(payloadElement.Value) as PrimitiveMultiValue; ExceptionUtilities.CheckObjectNotNull(replacedCollection, "Replaced complex collection was null or wrong type"); if (!this.ShouldReplace(payloadElement.Value, replacedCollection)) { return(payloadElement); } return(payloadElement.ReplaceWith(new PrimitiveMultiValueProperty(payloadElement.Name, replacedCollection))); }
/// <summary> /// Normalizes primitive multi-value properties, potentially replacing them with primitive collections if the metadata indicates the payload is from a service operation /// </summary> /// <param name="payloadElement">The payload element to potentially replace</param> /// <returns>The original element or a copy to replace it with</returns> public override ODataPayloadElement Visit(PrimitiveMultiValueProperty payloadElement) { var replaced = base.Visit(payloadElement); if (replaced.ElementType == ODataPayloadElementType.PrimitiveMultiValueProperty) { payloadElement = (PrimitiveMultiValueProperty)replaced; if (this.ShouldReplaceWithCollection(payloadElement, payloadElement.Value.IsNull, payloadElement.Value.FullTypeName)) { return payloadElement .ReplaceWith(new PrimitiveCollection(payloadElement.Value.ToArray())) .WithAnnotations(new CollectionNameAnnotation() { Name = payloadElement.Name }); } } return replaced; }
/// <summary> /// Normalizes primitive multi-value properties, potentially replacing them with primitive collections if the metadata indicates the payload is from a service operation /// </summary> /// <param name="payloadElement">The payload element to potentially replace</param> /// <returns>The original element or a copy to replace it with</returns> public override ODataPayloadElement Visit(PrimitiveMultiValueProperty payloadElement) { var replaced = base.Visit(payloadElement); if (replaced.ElementType == ODataPayloadElementType.PrimitiveMultiValueProperty) { payloadElement = (PrimitiveMultiValueProperty)replaced; if (this.ShouldReplaceWithCollection(payloadElement, payloadElement.Value.IsNull, payloadElement.Value.FullTypeName)) { return(payloadElement .ReplaceWith(new PrimitiveCollection(payloadElement.Value.ToArray())) .WithAnnotations(new CollectionNameAnnotation() { Name = payloadElement.Name })); } } return(replaced); }